Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
Fixed remaining issues with the new test cases
  • Loading branch information
michaelglenister authored and milafrerichs committed May 31, 2021
1 parent 6c5557c commit 1ce6ec9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tests/datasets/test_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,37 +265,42 @@ def test_subindicators_update(self, dataset, datasetData, subindicatorGroup):
assert groups[1].subindicators == ["X", "Y"]

def test_new_dataset_same_group_name(self, dataset, datasetData, subindicatorGroup):
# Make sure datasets with new subindicators are not leaking into groups with the same name from previous datasets
# Make sure new datasets with the same group name do not have subindicators from previous datasets
new_dataset = DatasetFactory()

DatasetDataFactory(
dataset=new_dataset, data={
'group1': 'D', 'group2': 'Z'
'group1': 'C', 'group2': 'Z'
}
)

groups = dataloader.create_groups(new_dataset, ["group1", "group2"])

assert len(groups) == 2
assert groups[0].subindicators == ["D"]
assert groups[0].subindicators != ["A", "B", "C", "D"]
assert groups[0].subindicators == ["C"]
assert groups[0].subindicators != ["A", "B", "C"]
assert groups[1].subindicators == ["Z"]
assert groups[1].subindicators != ["X", "Y", "Z"]

def test_old_dataset_does_not_include_new_subindicators(self, dataset, datasetData, subindicatorGroup):
# Make sure same group names from a previous dataset does not have subindicators leaking into it
new_dataset = DatasetFactory()

DatasetDataFactory(
dataset=dataset, data={
'group1': 'C', 'group2': 'Z'
dataset=new_dataset, data={
'group1': 'D', 'group2': 'W'
}
)

new_groups = dataloader.create_groups(new_dataset, ["group1", "group2"])
groups = dataloader.create_groups(dataset, ["group1", "group2"])

assert len(groups) == 2
assert groups[0].subindicators == ["A", "B", "C"]
assert new_groups[0].subindicators == ["D"]
assert new_groups[1].subindicators == ["W"]

assert groups[0].subindicators == ["A", "B"]
assert groups[0].subindicators != ["D"]
assert groups[1].subindicators == ["X", "Y", "Z"]
assert groups[1].subindicators != ["Z"]
assert groups[1].subindicators == ["X", "Y"]
assert groups[1].subindicators != ["W"]

0 comments on commit 1ce6ec9

Please sign in to comment.