Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Academies database connection - create fake data generator #172

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions DfE.FindInformationAcademiesTrusts.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DfE.FindInformationAcademie
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DfE.FindInformationAcademiesTrusts.Data", "DfE.FindInformationAcademiesTrusts.Data\DfE.FindInformationAcademiesTrusts.Data.csproj", "{DC3BD883-B6DA-4C54-85CB-2CD5D261E8FE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker", "tests\DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker\DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker.csproj", "{CE03C6BD-0160-4265-A287-3EC70103E4C9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -38,9 +40,14 @@ Global
{DC3BD883-B6DA-4C54-85CB-2CD5D261E8FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC3BD883-B6DA-4C54-85CB-2CD5D261E8FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC3BD883-B6DA-4C54-85CB-2CD5D261E8FE}.Release|Any CPU.Build.0 = Release|Any CPU
{CE03C6BD-0160-4265-A287-3EC70103E4C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE03C6BD-0160-4265-A287-3EC70103E4C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE03C6BD-0160-4265-A287-3EC70103E4C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE03C6BD-0160-4265-A287-3EC70103E4C9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0A3416F9-33DB-4870-97EA-7CFF8D828031} = {E22DC2DA-4EB5-41C6-A41D-349692BCCDBE}
{E20D30CB-8EB1-453B-8C49-77CAFBF16A13} = {E22DC2DA-4EB5-41C6-A41D-349692BCCDBE}
{CE03C6BD-0160-4265-A287-3EC70103E4C9} = {E22DC2DA-4EB5-41C6-A41D-349692BCCDBE}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker.Helpers;

namespace DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker;

public static class Data
{
/// <summary>
/// Trust names have been generated by Chat GPT AI and are fictional.
/// Any resemblance to real Trusts is entirely unintentional. If you spot a
/// real name then please raise a PR to correct it to a fake one
/// </summary>
public static TrustToGenerate[] TrustsToGenerate { get; } =
{
new("ABBEY LANE ACADEMIES TRUST"),
new("EDIFY MULTI-ACADEMY TRUST"),
new("INNOVATE ACADEMY TRUST"),
new("MOMENTUM MULTI-ACADEMY TRUST"),
new("VANGUARD LEARNING TRUST"),
new("PROGRESSIVE EDUCATION TRUST"),
new("HORIZON MULTI-ACADEMY TRUST"),
new("ELEVATE SCHOOLS TRUST"),
new("VISIONARY ACADEMY TRUST"),
new("EMPOWERMENT MULTI-ACADEMY TRUST"),
new("ECHELON EDUCATION TRUST"),
new("ASCENDANCY ACADEMY TRUST"),
new("NEXUS MULTI-ACADEMY TRUST"),
new("MERIT ACADEMY TRUST"),
new("EPIC LEARNING TRUST"),
new("PEAK MULTI-ACADEMY TRUST"),
new("LEGACY EDUCATION TRUST"),
new("ACCLIVITY MULTI-ACADEMY TRUST"),
new("PINNACLE EDUCATION TRUST"),
new("THRIVE MULTI-ACADEMY TRUST"),
new("ELEVATED SCHOOLS TRUST"),
new("CHAMPION ACADEMY TRUST"),
new("INTREPID EDUCATION TRUST"),
new("PROSPECT MULTI-ACADEMY TRUST"),
new("NEW HORIZONS TRUST"),
new("MILESTONE MULTI-ACADEMY TRUST"),
new("GALVANIZE ACADEMY TRUST"),
new("CORNERSTONE MULTI-ACADEMY TRUST"),
new("INSPIRE MULTI-ACADEMY TRUST"),
new("SUCCESS MULTI-ACADEMY TRUST"),
new("BRIDGE EDUCATION TRUST"),
new("CRESCENDO ACADEMY TRUST"),
new("POTENTIAL LEARNING TRUST"),
new("HORIZONS MULTI-ACADEMY TRUST"),
new("RISE EDUCATION TRUST"),
new("EXCEL MULTI-ACADEMY TRUST"),
new("UNITY LEARNING TRUST"),
new("ADEPT ACADEMY TRUST"),
new("EXCELLENCE MULTI-ACADEMY TRUST"),
new("PROSPERITY EDUCATION TRUST"),
new("PATHFINDER MULTI-ACADEMY TRUST"),
new("VITALITY ACADEMY TRUST"),
new("FORWARD MULTI-ACADEMY TRUST"),
new("TRANSCENDENCE EDUCATION TRUST"),
new("ADVANTAGE ACADEMY TRUST"),
new("ILLUMINATE MULTI-ACADEMY TRUST"),
new("FUSION EDUCATION TRUST"),
new("EMPOWER ACADEMY TRUST"),
new("ILLUMINATE LEARNING TRUST"),
new("CHALLENGER MULTI-ACADEMY TRUST"),
new("ST MARY'S ACADEMY TRUST", "Single-academy trust", "St. Mary's Academy"),
new("ST MARY'S ANGLICAN ACADEMY", "Single-academy trust", "St. Mary's Anglican Academy"),
new("ST MARY'S CATHOLIC HIGH SCHOOL ACADEMY TRUST", "Single-academy trust",
"St. Mary's Catholic High School Academy"),
new("ST MARY'S CATHOLIC PRIMARY SCHOOL", "Single-academy trust", "St. Mary's Catholic Primary School"),
new("ST MARY'S CATHOLIC PRIMARY SCHOOL (ACADEMY TRUST), SWINDON",
"Single-academy trust", "St. Mary's Catholic Primary School"),
new("ST MARY'S CATHOLIC PRIMARY SCHOOL (HERRINGTHORPE), A CATHOLIC VOLUNTARY ACADEMY",
"Single-academy trust", "St. Mary's Catholic Primary School"),
new("ST MARY'S CATHOLIC PRIMARY SCHOOL (MALTBY)", "Single-academy trust", "St. Mary's Catholic Primary School"),
new("ST MARY'S CATHOLIC PRIMARY SCHOOL, CHURCHDOWN", "Single-academy trust",
"St. Mary's Catholic Primary School"),
new("ST MARY'S CATHOLIC PRIMARY SCHOOLS TRUST", "Multi-academy trust",
"St Mary's Catholic Primary School", "St. Mary's Catholic Primary School",
"St. Marys Catholic Primary School", "St. Mary's Catholic Primary School",
"St Marys Catholic Primary School", "St. Mary's Catholic Primary School", "St. Mary's RC Primary School",
"St. Mary's Primary School", "St. Mary's Primary School"),
new("ST MARY'S CE ACADEMY, CHESHUNT", "Single-academy trust", "St Mary's CE Academy"),
new("ST MARY'S CHURCH OF ENGLAND ACADEMY TRUST", "Single-academy trust", "St Mary's Church of England Academy"),
new("ST MARY'S CHURCH OF ENGLAND ACADEMY, STOTFOLD", "Single-academy trust", "St Mary's Cofe Academy"),
new("ST MARY'S CHURCH OF ENGLAND JUNIOR SCHOOL", "Single-academy trust", "St Mary's C.E. Academy"),
new("ST MARY'S CHURCH OF ENGLAND PRIMARY ACADEMY, DILWYN", "Single-academy trust", "St Mary's C/E Academy"),
new("ST MARY'S CHURCH OF ENGLAND SCHOOL, NORWOOD GREEN", "Single-academy trust", "St Mary's C of E Academy"),
new("ST MARY'S CHURCH OF ENGLAND VA PRIMARY ACADEMY", "Single-academy trust",
"St Mary's Church of England VA Primary Academy"),
new("ST MARY'S PRIMARY SCHOOL, A CATHOLIC VOLUNTARY ACADEMY",
"Single-academy trust", "St Mary's Primary School, A Catholic Voluntary Academy"),
new("THE DIOCESE OF CANTERBURY ACADEMIES TRUST"),
new("THE DIOCESE OF CHELMSFORD VINE SCHOOLS TRUST"),
new("THE DIOCESE OF COVENTRY MULTI-ACADEMY TRUST"),
new("THE DIOCESE OF ELY MULTI-ACADEMY TRUST"),
new("THE DIOCESE OF GLOUCESTER ACADEMIES TRUST"),
new("THE DIOCESE OF NORWICH EDUCATION AND ACADEMIES TRUST"),
new("THE DIOCESE OF NORWICH ST BENET'S MULTI-ACADEMY TRUST"),
new("THE DIOCESE OF SHEFFIELD ACADEMIES TRUST"),
new("THE DIOCESE OF WESTMINSTER ACADEMY TRUST"),
new("THE DIOCESE OF WORCESTER MULTI ACADEMY TRUST"),
new("SHEFFIELD SOUTH EAST TRUST"),
new("CANTERBURY CROSS EDUCATION TRUST"),
new("WESTMINSTER ACADEMY TRUST")
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<RootNamespace>DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="34.0.2"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\DfE.FindInformationAcademiesTrusts.Data.AcademiesDb\DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.csproj"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Bogus;
using DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker.Helpers;
using DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Models;

namespace DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker.Fakers;

public class GroupFaker
{
private readonly Faker<Group> _groupFaker;

public GroupFaker(TrustToGenerate trustToGenerate)
{
_groupFaker = new Faker<Group>("en_GB")
.RuleFor(t => t.GroupName, trustToGenerate.Name)
.RuleFor(t => t.GroupUid, f => $"{f.Random.Int(1000, 9999)}")
.RuleFor(td => td.GroupId, f => $"TR{f.Random.Int(0, 9999)}")
.RuleFor(td => td.GroupType, trustToGenerate.TrustType)
.RuleFor(td => td.GroupContactStreet, f => $"{f.Address.BuildingNumber()} {f.Address.StreetName()}")
.RuleFor(td => td.GroupContactLocality, f => f.PickRandom(f.Address.StreetName(), string.Empty))
.RuleFor(td => td.GroupContactTown, f => f.PickRandom(f.Address.City(), string.Empty))
.RuleFor(td => td.GroupContactCounty, f => f.PickRandom(f.Address.County(), "Not recorded"))
.RuleFor(td => td.GroupContactPostcode, f => f.Address.ZipCode());
}

public Group Generate()
{
return _groupFaker.Generate();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker.Helpers;

public class TrustToGenerate
{
public TrustToGenerate(string name, string trustType = "Multi-academy trust", params string[] schools)
{
if (trustType == "Single-academy trust" && schools.Length != 1)
throw new ArgumentException("Single academy trusts must have one school specified");

Name = name;
TrustType = trustType;
Schools = schools;
}

public string Name { get; }
public string TrustType { get; }
public string[] Schools { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Text.Json;
using Bogus;
using DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker.Fakers;
using DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker.Helpers;
using DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Models;

namespace DfE.FindInformationAcademiesTrusts.Data.AcademiesDb.Faker;

internal static class Program
{
public static void Main(string[] args)
{
//The randomizer seed enables us to generate slightly repeatable data sets
Randomizer.Seed = new Random(28698);

var fakeGroups = Data.TrustsToGenerate
.Select(GenerateGroup)
.ToArray();

var serializeOptions = new JsonSerializerOptions
{
WriteIndented = true
};

File.WriteAllText("output.json", JsonSerializer.Serialize(fakeGroups, serializeOptions));
}

private static Group GenerateGroup(TrustToGenerate trustToGenerate)
{
var fakeGroup = new GroupFaker(trustToGenerate);
return fakeGroup.Generate();
}
}