Skip to content

Commit

Permalink
update migration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elichad committed Jun 19, 2023
1 parent a5708da commit a6288ed
Showing 1 changed file with 1 addition and 63 deletions.
64 changes: 1 addition & 63 deletions amy/workshops/tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,6 @@ def test_workshops_0259_existing_requirements(self):
)

# second migration step:
# test that deprecated training requirements were removed
for item in [
"SWC Demo",
"SWC Homework",
"DC Demo",
"DC Homework",
"LC Demo",
"LC Homework",
]:
with self.assertRaises(TrainingRequirement.DoesNotExist):
TrainingRequirement.objects.get(name=item)

# test that progresses have been moved to the correct requirements
for prefix in ["SWC", "DC", "LC"]:
self.assertEqual(
Expand Down Expand Up @@ -183,19 +171,6 @@ def test_workshops_0259_new_requirements(self):
self.assertFalse(demo.url_required)
self.assertTrue(contribution.url_required)

# test that deprecated training requirements were removed
for item in [
"SWC Demo",
"SWC Homework",
"DC Demo",
"DC Homework",
"LC Demo",
"LC Homework",
"Discussion",
]:
with self.assertRaises(TrainingRequirement.DoesNotExist):
TrainingRequirement.objects.get(name=item)

# test that progresses have been moved to the correct generic requirements
for prefix in ["SWC", "DC", "LC"]:
self.assertEqual(
Expand Down Expand Up @@ -233,12 +208,7 @@ def prepare(self):
)

welcome = TrainingRequirement.objects.get(name="Welcome Session")
demo = TrainingRequirement.objects.get(name="Demo")
contribution = TrainingRequirement.objects.get(name="Lesson Contribution")

TrainingProgress.objects.create(trainee=self.ironman, requirement=welcome)
TrainingProgress.objects.create(trainee=self.ironman, requirement=demo)
TrainingProgress.objects.create(trainee=self.ironman, requirement=contribution)

def test_workshops_0259_rollback(self):
TrainingRequirement = self.new_state.apps.get_model(
Expand All @@ -248,39 +218,7 @@ def test_workshops_0259_rollback(self):
"workshops", "TrainingProgress"
)

# second migration step rollback:
# test that deprecated requirements were added back in,
# and Demo and Lesson Contribution were not removed
for item in [
"Demo",
"Lesson Contribution",
"SWC Demo",
"SWC Homework",
"DC Demo",
"DC Homework",
"LC Demo",
"LC Homework",
]:
TrainingRequirement.objects.get(name=item)

# test that Demo/Lesson Contribution progresses were not changed
for prefix in ["SWC", "DC", "LC"]:
self.assertEqual(
TrainingProgress.objects.filter(
requirement__name__startswith=prefix
).count(),
0,
)

self.assertEqual(
TrainingProgress.objects.filter(requirement__name="Demo").count(), 1
)
self.assertEqual(
TrainingProgress.objects.filter(
requirement__name="Lesson Contribution"
).count(),
1,
)
# second migration step rollback: nothing happens

# first migration step rollback:
# test that Discussion was renamed to Welcome Session
Expand Down

0 comments on commit a6288ed

Please sign in to comment.