def test_change_group(self): """Check that when changing an institutes group, old accounts are removed from the institute and new ones are added. """ account1 = simple_account(machine_category=self.machine_category) group1 = GroupFactory() institute = InstituteFactory(group=group1) # Test setting up initial group for institute self.resetDatastore() group1.save() group1.add_person(account1.person) self.assertEqual(self.datastore.method_calls, [ mock.call.save_group(group1), mock.call.add_account_to_group(account1, group1) ]) # Test during initial creation of the institute self.resetDatastore() institute_quota = InstituteQuota.objects.create( machine_category=self.machine_category, institute=institute, quota=100) self.assertEqual(self.datastore.method_calls, [ mock.call.save_institute(institute), mock.call.add_account_to_institute(account1, institute) ]) # Test changing an existing institutions group account2 = simple_account(institute=institute, machine_category=self.machine_category) self.resetDatastore() group2 = GroupFactory() group2.add_person(account2.person) institute.group = group2 institute.save() self.assertEqual( self.datastore.method_calls, [ mock.call.save_group(group2), mock.call.add_account_to_group(account2, group2), mock.call.save_institute(institute), # old accounts are removed mock.call.remove_account_from_institute(account1, institute), # new accounts are added mock.call.add_account_to_institute(account2, institute) ]) # Test deleting project quota self.resetDatastore() institute_quota.delete() self.assertEqual(self.datastore.method_calls, [ mock.call.remove_account_from_institute(account2, institute), mock.call.delete_institute(institute) ])
def test_change_group(self): """Check that when changing an institutes group, old accounts are removed from the institute and new ones are added. """ account1 = simple_account() group1 = GroupFactory() # Test initial creation of the institute self.resetDatastore() institute = InstituteFactory(group=group1) self.assertEqual( self.datastore.method_calls, [mock.call.save_institute(institute)]) # Test setting up initial group for institute self.resetDatastore() group1.save() group1.add_person(account1.person) self.assertEqual( self.datastore.method_calls, [mock.call.save_group(group1), mock.call.add_account_to_group(account1, group1), mock.call.add_account_to_institute(account1, institute)]) # Test changing an existing institutions group account2 = simple_account(institute=institute) self.resetDatastore() group2 = GroupFactory() group2.add_person(account2.person) group2.save() institute.group = group2 institute.save() self.assertEqual( self.datastore.method_calls, [mock.call.save_group(group2), mock.call.add_account_to_group(account2, group2), mock.call.save_group(group2), mock.call.save_institute(institute), # old accounts are removed mock.call.remove_account_from_institute(account1, institute), # new accounts are added mock.call.add_account_to_institute(account2, institute)]) # Test deleting institute self.resetDatastore() institute.delete() self.assertEqual( self.datastore.method_calls, [mock.call.remove_account_from_institute(account2, institute), mock.call.delete_institute(institute)])
def test_change_group(self): """Check that when changing an institutes group, old accounts are removed from the institute and new ones are added. """ account1 = simple_account(machine_category=self.machine_category) group1 = GroupFactory() # Test during initial creation of the institute self.resetDatastore() institute = InstituteFactory(group=group1) group1.parent = institute group1.save() group1.add_person(account1.person) institute_quota = InstituteQuota.objects.create( machine_category=self.machine_category, institute=institute, quota=100) self.assertEqual( self.datastore.method_calls, [mock.call.save_institute(institute), mock.call.add_account_to_institute(account1, institute)]) # Test changing an existing institutions group account2 = simple_account(institute=institute, machine_category=self.machine_category) self.resetDatastore() group2 = GroupFactory() group2.add_person(account2.person) institute.group = group2 institute.save() self.assertEqual( self.datastore.method_calls, [mock.call.save_group(group2), mock.call.add_account_to_group(account2, group2), mock.call.save_institute(institute), # old accounts are removed mock.call.remove_account_from_institute(account1, institute), # new accounts are added mock.call.add_account_to_institute(account2, institute)]) # Test deleting project quota self.resetDatastore() institute_quota.delete() self.assertEqual( self.datastore.method_calls, [mock.call.remove_account_from_institute(account2, institute), mock.call.delete_institute(institute)])
def test_change_group(self): """Check that when changing an software group, old accounts are removed from the software and new ones are added. """ account1 = simple_account(machine_category=self.machine_category) group1 = GroupFactory() group1.add_person(account1.person) # Test during initial creation of the software self.resetDatastore() software = SoftwareFactory(group=group1) self.assertEqual( self.datastore.method_calls, [mock.call.save_software(software), mock.call.add_account_to_software(account1, software)]) # Test changing an existing software group account2 = simple_account(machine_category=self.machine_category) self.resetDatastore() group2 = GroupFactory() group2.add_person(account2.person) software.group = group2 software.save() self.assertEqual( self.datastore.method_calls, [mock.call.save_group(group2), mock.call.add_account_to_group(account2, group2), mock.call.save_software(software), # old accounts are removed mock.call.remove_account_from_software(account1, software), # new accounts are added mock.call.add_account_to_software(account2, software)])
def test_change_group(self): """Check that when changing an projects group, old accounts are removed from the project and new ones are added. """ account1 = simple_account(machine_category=self.machine_category) group1 = GroupFactory() group1.add_person(account1.person) institute = InstituteFactory() # Test during initial creation of the project self.resetDatastore() project = Project.objects.create(group=group1, institute=institute) project_quota = ProjectQuota.objects.create( machine_category=self.machine_category, project=project) self.assertEqual(self.datastore.method_calls, [ mock.call.save_project(project), mock.call.add_account_to_project(account1, project) ]) # Test changing an existing projects group account2 = simple_account(machine_category=self.machine_category) self.resetDatastore() group2 = GroupFactory() group2.add_person(account2.person) project.group = group2 project.save() self.assertEqual( self.datastore.method_calls, [ mock.call.save_group(group2), mock.call.add_account_to_group(account2, group2), mock.call.save_project(project), # old accounts are removed mock.call.remove_account_from_project(account1, project), # new accounts are added mock.call.add_account_to_project(account2, project) ]) # Test deleting project quota self.resetDatastore() project_quota.delete() self.assertEqual(self.datastore.method_calls, [ mock.call.remove_account_from_project(account2, project), mock.call.delete_project(project) ])
def test_change_group(self): """Check that when changing an software group, old accounts are removed from the software and new ones are added. """ account1 = simple_account() group1 = GroupFactory() group1.add_person(account1.person) # Test during initial creation of the software software = SoftwareFactory(group=group1) # Test changing an existing software group account2 = simple_account() group2 = GroupFactory() group2.add_person(account2.person) software.group = group2 software.save()
def test_change_group(self): """Check that when changing an projects group, old accounts are removed from the project and new ones are added. """ account1 = simple_account(machine_category=self.machine_category) group1 = GroupFactory() group1.add_person(account1.person) institute = InstituteFactory() # Test during initial creation of the project self.resetDatastore() project = Project.objects.create(group=group1, institute=institute) project_quota = ProjectQuota.objects.create( machine_category=self.machine_category, project=project) self.assertEqual( self.datastore.method_calls, [mock.call.save_project(project), mock.call.add_account_to_project(account1, project)]) # Test changing an existing projects group account2 = simple_account(machine_category=self.machine_category) self.resetDatastore() group2 = GroupFactory() group2.add_person(account2.person) project.group = group2 project.save() self.assertEqual( self.datastore.method_calls, [mock.call.save_group(group2), mock.call.add_account_to_group(account2, group2), mock.call.save_project(project), # old accounts are removed mock.call.remove_account_from_project(account1, project), # new accounts are added mock.call.add_account_to_project(account2, project)]) # Test deleting project quota self.resetDatastore() project_quota.delete() self.assertEqual( self.datastore.method_calls, [mock.call.remove_account_from_project(account2, project), mock.call.delete_project(project)])