def test_empty_recipients(self, recipients): """Test validation of empty recipients: '{}'""" validator = comment.Commentable.validate_recipients self.assertEqual( validator(all_models.Assessment(), "recipients", recipients), "" )
def test_empty_recipients(self, recipients): """Test validation of empty recipients: '{}'""" with patch(u"ggrc.access_control.role.get_ac_roles_for", return_value={}): validator = comment.Commentable.validate_recipients self.assertEqual( validator(all_models.Assessment(), "recipients", recipients), "")
def test_create_new_assessment_with_mapped_control(self): "Test for creation assessment with mapped controls" with factories.single_commit(): audit = factories.AuditFactory() control = factories.ControlFactory() revision = all_models.Revision.query.filter( all_models.Revision.resource_id == control.id, all_models.Revision.resource_type == control.__class__.__name__ ).order_by( all_models.Revision.id.desc() ).first() factories.SnapshotFactory( parent=audit, child_id=control.id, child_type=control.__class__.__name__, revision_id=revision.id ) db.session.commit() self.assertFalse(db.session.query( all_models.Relationship.get_related_query( all_models.Assessment(), all_models.Snapshot() ).exists()).first()[0]) slug = "TestAssessment" response = self.import_data(OrderedDict([ ("object_type", "Assessment"), ("Code*", slug), ("Audit*", audit.slug), ("Assignees*", all_models.Person.query.all()[0].email), ("Creators", all_models.Person.query.all()[0].email), ("Title", "Strange title"), ("map:Control versions", control.slug), ])) self._check_csv_response(response, {}) assessment = all_models.Assessment.query.filter( all_models.Assessment.slug == slug ).first() self.assertTrue(db.session.query(all_models.Relationship.get_related_query( assessment, all_models.Snapshot()).exists()).first()[0] )