Skip to content

Commit

Permalink
[BIA-1316] Missing tests scenarios where COALESCE function is used. (#…
Browse files Browse the repository at this point in the history
…233)

* Missing tests for SchoolDim.

* Missing tests for SectionDim 3.1, 3.2, 3.3. Postgres failing for DS 3.3.

* Missing tests for SectionDim 3.3 Postgres fixed.

* Missing tests for SectionDim 2.0. Adds data.

* Since FeederSchoolId is a not null value, that COALESCE on FeederSchoolDim is not necessary.

* Since StaffEducationOrganizationAssignmentAssociation.EducationOrganizationId is a not null value, 2 COALESCE calls on rls_UserAuthorization are not necessary.
  • Loading branch information
DavidJGapCR authored Jan 12, 2023
1 parent d060f9b commit 45ac263
Show file tree
Hide file tree
Showing 24 changed files with 501 additions and 382 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ AS
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
THEN CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
ELSE ''
END AS DistrictId
FROM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AS
SELECT
CONCAT(FeederSchoolAssociation.SchoolId,'-',FeederSchoolAssociation.FeederSchoolId) AS FeederSchoolUniqueKey
,CAST(FeederSchoolAssociation.SchoolId AS VARCHAR) AS SchoolKey
,COALESCE(CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR), '') AS FeederSchoolKey
,CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR) AS FeederSchoolKey
,EducationOrganization.NameOfInstitution AS FeederSchoolName
,(
SELECT MAX(MaxLastModifiedDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ SELECT DISTINCT staffToScopeMap.StaffUniqueId AS UserKey
,CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
THEN CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
ELSE ''
END AS DistrictId
FROM staffToScopeMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AS
SELECT
CONCAT(FeederSchoolAssociation.SchoolId,'-',FeederSchoolAssociation.FeederSchoolId) AS FeederSchoolUniqueKey
,CAST(FeederSchoolAssociation.SchoolId AS VARCHAR) AS SchoolKey
,COALESCE(CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR), '') AS FeederSchoolKey
,CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR) AS FeederSchoolKey
,EducationOrganization.NameOfInstitution AS FeederSchoolName
,(
SELECT MAX(MaxLastModifiedDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ AS
SELECT
CONCAT(FeederSchoolAssociation.SchoolId,'-',FeederSchoolAssociation.FeederSchoolId) AS FeederSchoolUniqueKey
,CAST(FeederSchoolAssociation.SchoolId AS VARCHAR) AS SchoolKey
,COALESCE(CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR), '') AS FeederSchoolKey
,CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR) AS FeederSchoolKey
,EducationOrganization.NameOfInstitution AS FeederSchoolName
,(
SELECT MAX(MaxLastModifiedDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ SELECT DISTINCT staffToScopeMap.StaffUniqueId AS UserKey
,CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
THEN CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
ELSE ''
END AS DistrictId
FROM staffToScopeMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ AS
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR),'')
THEN CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
ELSE ''
END AS DistrictId
FROM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CREATE VIEW analytics.SectionDim AS
,COALESCE(SectionClassPeriod.LocalCourseCode,CourseOffering.LocalCourseCode) as LocalCourseCode
,CAST(COALESCE(Session.SchoolYear,CourseOffering.SchoolYear) as VARCHAR) as SchoolYear
,eed.Description AS EducationalEnvironmentDescriptor
,CAST(sch.LocalEducationAgencyId AS VARCHAR) as LocalEducationAgencyKey
,COALESCE(CAST(sch.LocalEducationAgencyId AS VARCHAR), '') as LocalEducationAgencyKey
,s.LastModifiedDate
,course.CourseTitle
,FORMAT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AS
SELECT
CONCAT(FeederSchoolAssociation.SchoolId,'-',FeederSchoolAssociation.FeederSchoolId) AS FeederSchoolUniqueKey
,CAST(FeederSchoolAssociation.SchoolId AS VARCHAR) AS SchoolKey
,COALESCE(CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR), '') AS FeederSchoolKey
,CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR) AS FeederSchoolKey
,EducationOrganization.NameOfInstitution AS FeederSchoolName
,(
SELECT MAX(MaxLastModifiedDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ AS
SELECT
CONCAT(FeederSchoolAssociation.SchoolId,'-',FeederSchoolAssociation.FeederSchoolId) AS FeederSchoolUniqueKey
,cast(FeederSchoolAssociation.SchoolId as varchar) AS SchoolKey
,COALESCE(CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR), '') AS FeederSchoolKey
,CAST(FeederSchoolAssociation.FeederSchoolId AS VARCHAR) AS FeederSchoolKey
,EducationOrganization.NameOfInstitution AS FeederSchoolName
,(
SELECT MAX(MaxLastModifiedDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ SELECT DISTINCT staffToScopeMap.StaffUniqueId AS UserKey
,CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
THEN CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
ELSE ''
END AS DistrictId
FROM staffToScopeMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ AS
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE COALESCE(CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR), '')
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN COALESCE(cast(staffToScopeMap.EducationOrganizationId as varchar), '')
THEN cast(staffToScopeMap.EducationOrganizationId as varchar)
ELSE ''
END AS DistrictId
FROM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,34 @@ public void Then_StateEducationAgencyName_is_replaced_with_empty()
testResult.success.ShouldBe(true, testResult.errorMessage);
}

[Test]
public void Then_StateEducationAgencyKey_is_replaced_with_empty()
{
(bool success, string errorMessage) testResult = DataStandard.RunTestCase<SchoolDim>($"{TestCasesFolder}.When_EdOrgState.StateEducationAgencyKey_is_null.json");
testResult.success.ShouldBe(true, testResult.errorMessage);
}

[Test]
public void Then_EducationServiceCenterName_is_replaced_with_empty()
{
(bool success, string errorMessage) testResult = DataStandard.RunTestCase<SchoolDim>($"{TestCasesFolder}.When_EdOrgServiceCenter.NameOfInstitution_is_null.json");
testResult.success.ShouldBe(true, testResult.errorMessage);
}

[Test]
public void Then_EducationServiceCenterKey_is_replaced_with_empty()
{
(bool success, string errorMessage) testResult = DataStandard.RunTestCase<SchoolDim>($"{TestCasesFolder}.When_EdOrgServiceCenter.EducationServiceCenterKey_is_null.json");
testResult.success.ShouldBe(true, testResult.errorMessage);
}

[Test]
public void Then_LocalEducationAgencyKey_is_replaced_with_empty()
{
(bool success, string errorMessage) testResult = DataStandard.RunTestCase<SchoolDim>($"{TestCasesFolder}.When_EdOrgLocal.LocalEducationAgencyKey_is_null.json");
testResult.success.ShouldBe(true, testResult.errorMessage);
}

[Test]
public void Then_the_SchoolAddress_returned_is_the_physical_address_and_not_mailing_address()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ public void Then_should_have_SessionKey()
}
}

public class When_querying_the_SectionDim_view_with_LocalCourseCode_QAGR40
: When_querying_the_SectionDim_view_base
{
public When_querying_the_SectionDim_view_with_LocalCourseCode_QAGR40(TestHarnessBase dataStandard) => SetDataStandard(dataStandard);

private const string _caseIdentifier = "QAGR40";

[Test]
public void Then_should_have_LocalEducationAgencyKey()
{
(bool success, string errorMessage) testResult = DataStandard.RunTestCase<SectionDim>($"{TestCasesFolder}.{_caseIdentifier}_should_have_LocalEducationAgencyKey.xml");
testResult.success.ShouldBe(true, testResult.errorMessage);
}
}

[SuppressMessage("ReSharper", "InconsistentNaming")]
public class When_querying_the_SectionDim_V2_view
: When_querying_the_SectionDim_view_base
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"DBMS": "Any",
"ControlDataInsertion": "",
"DropControlData": "",
"Query": "select LocalEducationAgencyKey from analytics.SchoolDim where SchoolKey = '867530010'",
"Result": [
{
"LocalEducationAgencyKey": ""
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"DBMS": "Any",
"ControlDataInsertion": "",
"DropControlData": "",
"Query": "select EducationServiceCenterKey from analytics.SchoolDim where SchoolKey = '867530010'",
"Result": [
{
"EducationServiceCenterKey": ""
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"DBMS": "Any",
"ControlDataInsertion": "",
"DropControlData": "",
"Query": "select StateEducationAgencyKey from analytics.SchoolDim where SchoolKey = '867530010'",
"Result": [
{
"StateEducationAgencyKey": ""
}
]
}
Loading

0 comments on commit 45ac263

Please sign in to comment.