-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from DFE-Digital/feature/project-tasks
SPIKE for configuring project tasks Needs team discussion about how well this works The tasks have been made up to test the limits, they are not part of the requirements
- Loading branch information
Showing
51 changed files
with
25,033 additions
and
77 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...hoolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/Tasks/ConstructionTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks | ||
{ | ||
public record ConstructionTask | ||
{ | ||
public string NameOfSite { get; set; } | ||
public string AddressOfSite { get; set; } | ||
public string PostcodeOfSite { get; set; } | ||
public string BuildingType { get; set; } | ||
public string TrustRef { get; set; } | ||
public string TrustLeadSponsor { get; set; } | ||
public string TrustName { get; set; } | ||
public string SiteMinArea { get; set; } | ||
public string TypeofWorksLocation { get; set; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...eFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/Tasks/DatesTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks | ||
{ | ||
|
||
public record DatesTask | ||
{ | ||
public string DateOfEntryIntoPreopening { get; set; } | ||
public string RealisticYearOfOpening { get; set; } | ||
public string ProvisionalOpeningDateAgreedWithTrust { get; set; } | ||
public string ActualOpeningDate { get; set; } | ||
public string OpeningAcademicYear { get; set; } | ||
public string StartOfTermDate { get; set; } | ||
public string ProvisionalKickoffMeetingDate { get; set; } | ||
public string ActualKickOffMeetingDate { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/Tasks/GetProjectByTaskResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks | ||
{ | ||
public class GetProjectByTaskResponse | ||
{ | ||
public RiskAppraisalTask RiskAppraisal { get; set; } | ||
public DatesTask Dates { get; set; } | ||
public SchoolTask School { get; set; } | ||
public ConstructionTask Construction { get; set; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
.../Dfe.ManageFreeSchoolProjects.API.Contracts/Project/Tasks/ProjectByTaskSummaryResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks | ||
{ | ||
public class ProjectByTaskSummaryResponse | ||
{ | ||
public TaskSummaryResponse School { get; set; } | ||
|
||
public TaskSummaryResponse Construction { get; set; } | ||
} | ||
|
||
public class TaskSummaryResponse | ||
{ | ||
public string Name { get; set; } | ||
public ProjectTaskStatus Status { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...oolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/Tasks/ProjectTaskStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks | ||
{ | ||
public enum ProjectTaskStatus | ||
{ | ||
NotStarted = 1, | ||
InProgress = 2, | ||
Completed = 3 | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...choolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/Tasks/ProjectTaskType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks | ||
{ | ||
public enum ProjectTaskType | ||
{ | ||
Unknown = 0, | ||
Dates = 1, | ||
RiskAppraisal = 2 | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...oolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/Tasks/RiskAppraisalTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks | ||
{ | ||
public record RiskAppraisalTask | ||
{ | ||
public string SharepointLink { get; set; } | ||
public string EducationRiskRating { get; set; } | ||
public string GovernanceRiskRating { get; set; } | ||
public string FinanceRiskRating { get; set; } | ||
public bool MarkedAsComplete { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...FreeSchoolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/Tasks/SchoolTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks | ||
{ | ||
public record SchoolTask | ||
{ | ||
public string SchoolType { get; set; } | ||
public string SchoolPhase { get; set; } | ||
public string AgeRange { get; set; } | ||
public string Nursery { get; set; } | ||
public string SixthForm { get; set; } | ||
public string CompanyName { get; set; } | ||
public string NumberOfCompanyMembers { get; set; } | ||
public string ProposedChairOfTrustees { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ts/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/Tasks/UpdateProjectByTaskRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks | ||
{ | ||
public class UpdateProjectByTaskRequest | ||
{ | ||
public RiskAppraisalTask RiskAppraisal { get; set; } | ||
public DatesTask Dates { get; set; } | ||
public SchoolTask School { get; set; } | ||
public ConstructionTask Construction { get; set; } | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...cts/Dfe.ManageFreeSchoolProjects.API.Tests/Integration/GetProjectByTaskSummaryApiTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks; | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.ResponseModels; | ||
using Dfe.ManageFreeSchoolProjects.API.Tests.Fixtures; | ||
using Dfe.ManageFreeSchoolProjects.API.Tests.Helpers; | ||
using System.Net; | ||
using System.Net.Http.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dfe.ManageFreeSchoolProjects.API.Tests.Integration | ||
{ | ||
[Collection(ApiTestCollection.ApiTestCollectionName)] | ||
public class GetProjectTaskSummaryApiTests : ApiTestsBase | ||
{ | ||
public GetProjectTaskSummaryApiTests(ApiTestFixture apiTestFixture) : base(apiTestFixture) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task GetProjectTaskList_Returns_200() | ||
{ | ||
using var context = _testFixture.GetContext(); | ||
var project = DatabaseModelBuilder.BuildProject(); | ||
|
||
context.Kpi.Add(project); | ||
await context.SaveChangesAsync(); | ||
|
||
var taskListResponse = await _client.GetAsync($"/api/v1/client/projects/{project.ProjectStatusProjectId}/tasks/summary"); | ||
taskListResponse.StatusCode.Should().Be(HttpStatusCode.OK); | ||
|
||
var content = await taskListResponse.Content.ReadFromJsonAsync<ApiSingleResponseV2<ProjectByTaskSummaryResponse>>(); | ||
|
||
var result = content.Data; | ||
|
||
result.School.Name.Should().Be("School"); | ||
result.School.Status.Should().Be(ProjectTaskStatus.NotStarted); | ||
result.Construction.Name.Should().Be("Construction"); | ||
result.Construction.Status.Should().Be(ProjectTaskStatus.InProgress); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...rojects/Dfe.ManageFreeSchoolProjects.API.Tests/Integration/UpdateProjectByTaskApiTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Tasks; | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.ResponseModels; | ||
using Dfe.ManageFreeSchoolProjects.API.Tests.Fixtures; | ||
using Dfe.ManageFreeSchoolProjects.API.Tests.Helpers; | ||
using System.Net; | ||
using System.Net.Http.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dfe.ManageFreeSchoolProjects.API.Tests.Integration | ||
{ | ||
[Collection(ApiTestCollection.ApiTestCollectionName)] | ||
public class UpdateProjectTaskApiTests : ApiTestsBase | ||
{ | ||
public UpdateProjectTaskApiTests(ApiTestFixture apiTestFixture) : base(apiTestFixture) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task Patch_SchoolTask_Returns_201() | ||
{ | ||
var project = DatabaseModelBuilder.BuildProject(); | ||
var projectId = project.ProjectStatusProjectId; | ||
|
||
using var context = _testFixture.GetContext(); | ||
context.Kpi.Add(project); | ||
await context.SaveChangesAsync(); | ||
|
||
var request = new UpdateProjectByTaskRequest() | ||
{ | ||
School = new SchoolTask() | ||
{ | ||
SchoolType = "Secondary", | ||
AgeRange = "11-18", | ||
SchoolPhase = "Opening", | ||
Nursery = "Yes", | ||
SixthForm = "Yes", | ||
CompanyName = "School Builders Ltd", | ||
NumberOfCompanyMembers = "100", | ||
ProposedChairOfTrustees = "Lemon Group Ltd" | ||
} | ||
}; | ||
|
||
var projectResponse = await UpdateProjectTask(projectId, request); | ||
|
||
projectResponse.School.SchoolType.Should().Be("Secondary"); | ||
projectResponse.School.SchoolPhase.Should().Be("Opening"); | ||
projectResponse.School.AgeRange.Should().Be("11-18"); | ||
projectResponse.School.Nursery.Should().Be("Yes"); | ||
projectResponse.School.SixthForm.Should().Be("Yes"); | ||
projectResponse.School.CompanyName.Should().Be("School Builders Ltd"); | ||
projectResponse.School.NumberOfCompanyMembers.Should().Be("100"); | ||
projectResponse.School.ProposedChairOfTrustees.Should().Be("Lemon Group Ltd"); | ||
} | ||
|
||
[Fact] | ||
public async Task Patch_ConstructionTask_Returns_201() | ||
{ | ||
var project = DatabaseModelBuilder.BuildProject(); | ||
var projectId = project.ProjectStatusProjectId; | ||
|
||
using var context = _testFixture.GetContext(); | ||
context.Kpi.Add(project); | ||
await context.SaveChangesAsync(); | ||
|
||
var request = new UpdateProjectByTaskRequest() | ||
{ | ||
Construction = new ConstructionTask() | ||
{ | ||
NameOfSite = "Lemon Site", | ||
AddressOfSite = "Fruitpickers Lane", | ||
PostcodeOfSite = "LF124YH", | ||
BuildingType = "Brick", | ||
TrustRef = "1234ABC", | ||
TrustLeadSponsor = "Aviva", | ||
TrustName = "Education First", | ||
SiteMinArea = "10000", | ||
TypeofWorksLocation = "Building site" | ||
} | ||
}; | ||
|
||
var projectResponse = await UpdateProjectTask(projectId, request); | ||
|
||
projectResponse.Construction.NameOfSite.Should().Be("Lemon Site"); | ||
projectResponse.Construction.AddressOfSite.Should().Be("Fruitpickers Lane"); | ||
projectResponse.Construction.PostcodeOfSite.Should().Be("LF124YH"); | ||
projectResponse.Construction.BuildingType.Should().Be("Brick"); | ||
projectResponse.Construction.TrustRef.Should().Be("1234ABC"); | ||
projectResponse.Construction.TrustLeadSponsor.Should().Be("Aviva"); | ||
projectResponse.Construction.TrustName.Should().Be("Education First"); | ||
projectResponse.Construction.SiteMinArea.Should().Be("10000"); | ||
projectResponse.Construction.TypeofWorksLocation.Should().Be("Building site"); | ||
} | ||
|
||
[Fact] | ||
public async Task Patch_Task_NoProjectExists_Returns_404() | ||
{ | ||
var request = new UpdateProjectByTaskRequest() | ||
{ | ||
}; | ||
|
||
var updateTaskResponse = await _client.PatchAsync($"/api/v1/client/projects/NotExist/tasks", request.ConvertToJson()); | ||
updateTaskResponse.StatusCode.Should().Be(HttpStatusCode.NotFound); | ||
} | ||
|
||
private async Task<GetProjectByTaskResponse> UpdateProjectTask(string projectId, UpdateProjectByTaskRequest request) | ||
{ | ||
var updateTaskResponse = await _client.PatchAsync($"/api/v1/client/projects/{projectId}/tasks", request.ConvertToJson()); | ||
updateTaskResponse.StatusCode.Should().Be(HttpStatusCode.OK); | ||
|
||
var getProjectByTaskResponse = await _client.GetAsync($"/api/v1/client/projects/{projectId}/tasks"); | ||
getProjectByTaskResponse.StatusCode.Should().Be(HttpStatusCode.OK); | ||
|
||
var result = await getProjectByTaskResponse.Content.ReadFromJsonAsync<ApiSingleResponseV2<GetProjectByTaskResponse>>(); | ||
|
||
return result.Data; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.