Skip to content

Commit

Permalink
An additional test to check for handling of modules with no programmes
Browse files Browse the repository at this point in the history
  • Loading branch information
profcturner committed Aug 29, 2019
1 parent ffb299e commit b36a16d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions loads/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,43 @@ def test_package_migration_programmes_modules(self):
self.assertEqual(len(Activity.objects.all().filter(activity_set=activity_set)), 1)


def test_package_migration_orphaned_modules(self):
"""A test for the correct migration of modules that have no parent programme"""
destination = WorkPackage.objects.get(name="destination")
source = WorkPackage.objects.get(name="source")

# Just copy programmes first
options = dict()
options['copy_programmes'] = True
options['copy_activities_generated'] = True
options['copy_activities_custom'] = True
options['copy_modules'] = True
options['copy_activities_modules'] = True
options['copy_modulestaff'] = True

# Orphan a module
module = Module.objects.get(module_code="ABC101")
# Remove the lead programme
module.lead_programme = None
for programme in module.programmes.all():
module.programmes.remove(programme)

# Now perform the clone
destination.clone_from(source, options)
# Attempt to run a second time to ensure idempotency
destination.clone_from(source, options)

# check the numbers of module in each package are correct
source_modules = Module.objects.all().filter(package=source).filter(module_code="ABC101")
self.assertEqual(len(source_modules), 1)
destination_modules = Module.objects.all().filter(package=destination).filter(module_code="ABC101")
self.assertEqual(len(destination_modules), 1)

# and modules
#source_module_ABC101 = source_modules.get(module_code="ABC101")
#destination_module_ABC101 = destination_modules.get(module_code="ABC101")


class AssessmentResourceTestCase(TestCase):
def setUp(self):
# Create a workpackage
Expand Down

0 comments on commit b36a16d

Please sign in to comment.