def setUp(self): super(TestIssueIntegration, self).setUp() self.verifier = create_rand_person() self.assignee = create_rand_person() self.admin_role = all_models.AccessControlRole.query.filter_by( object_type=all_models.Issue.__name__, name="Admin" ).first() self.primary_contact_role = all_models.AccessControlRole.query.filter_by( object_type=all_models.Issue.__name__, name="Primary Contacts" ).first()
def base_multiple_setup(self, model_name, field, operation): """Set up basic test fixture with the following data: - Persons and Roles - Searchable model instance - basic test cases """ persons = [] for _ in range(MULTIPLE_ITEMS_COUNT + 1): persons.append(create_rand_person()) setup_func = self.get_setup_func(operation, False) return setup_func(model_name, field, persons)
def base_single_setup(self, model_name, field, operation): """Set up basic test fixture with the following data: - Persons and Roles - Searchable model instance - basic test cases """ setup_func = self.get_setup_func(operation, True) objects = [] for _ in range(TEST_REPEAT_COUNT): objects.append(setup_func(model_name, field, create_rand_person())) return objects
def base_single_setup(self, model_name, field, operation): """Set up basic test fixture with the following data: - Persons and Roles - Searchable model instance - basic test cases """ setup_func = self.get_setup_func(operation, True) objects = [] for _ in range(TEST_REPEAT_COUNT): objects.append( setup_func(model_name, field, create_rand_person()) ) return objects
def test_sync_assignee_email(self): """Test adding new assignee email into Issue ACL.""" # Arrange test data. new_assignee = create_rand_person() iti = self.initialize_test_issuetracker_info() batches = [ { "1": { "status": "NEW", "type": "BUG", "priority": "P2", "severity": "S2", "verifier": self.verifier.email, "assignee": new_assignee.email, } } ] # Perform action. with mock.patch.object(flask.g, "global_role_names", None): with mock.patch.object(sync_utils, "iter_issue_batches", return_value=batches): issue_sync_job.sync_issue_attributes() issue = all_models.Issue.query.get(iti.issue_tracked_obj.id) # Check unchanged admins admin_emails = [ person.email for person in issue.get_persons_for_rolename("Admin") ] self.assertListEqual(admin_emails, [self.verifier.email, ]) # Check changed primary contacts primary_contacts_emails = [ person.email for person in issue.get_persons_for_rolename("Primary Contacts") ] self.assertListEqual( primary_contacts_emails, [new_assignee.email, ] )
def test_sync_issue_tracker_emails(self): """Test sync issue tracker emails. Current verifier should be replaced by new verifier from Issue Tracker. Current assignee should be replaced by new assignee from Issue Tracker. CCs list shouldn't be changed. Other Admins and Primary Contacts shouldn't be removed. """ # Arrange test data. new_assignee = create_rand_person() new_verifier = create_rand_person() iti = self.initialize_test_issuetracker_info() # Add more admins into issue. second_verifier = create_rand_person() # Change names to be sure that names in alphabetical order. self.verifier.name = "A" + self.verifier.name second_verifier.name = "B" + second_verifier.name factories.AccessControlListFactory( ac_role=self.admin_role, object=iti.issue_tracked_obj, person=second_verifier ) # Add more primary contacts into issue. second_assignee = create_rand_person() # Change names to be sure that names in alphabetical order. self.assignee.name = "A" + self.assignee.name second_assignee.name = "B" + second_assignee.name factories.AccessControlListFactory( ac_role=self.primary_contact_role, object=iti.issue_tracked_obj, person=second_assignee ) batches = [ { "1": { "status": "NEW", "type": "BUG", "priority": "P2", "severity": "S2", "verifier": new_verifier.email, "assignee": new_assignee.email, } } ] # Perform action. with mock.patch.object(flask.g, "global_role_names", None): with mock.patch.object(sync_utils, "iter_issue_batches", return_value=batches): issue_sync_job.sync_issue_attributes() issue = all_models.Issue.query.get(iti.issue_tracked_obj.id) # Check changed admins. admin_emails = [ person.email for person in issue.get_persons_for_rolename("Admin") ] self.assertListEqual( admin_emails, [second_verifier.email, new_verifier.email, ] ) # Check changed primary contacts. primary_contacts_emails = [ person.email for person in issue.get_persons_for_rolename("Primary Contacts") ] self.assertListEqual( primary_contacts_emails, [second_assignee.email, new_assignee.email, ] )