def build_evidence(self, link, user_id): """Build evidence object""" evidence = all_models.Evidence( link=link, title=link, modified_by_id=user_id, context=self.row_converter.obj.context, kind=self.KIND, ) evidence.add_admin_role() return evidence
def test_create_invalid_type(self): """Test validation evidence_type.""" data = { 'kind': 'Wrong type', 'title': 'test_title', 'link': 'test_attachment', } obj_name = all_models.Evidence._inflector.table_singular obj = all_models.Evidence() obj_dict = self.gen.obj_to_dict(obj, obj_name) obj_dict[obj_name].update(data) resp = self.api.post(all_models.Evidence, obj_dict) self.assert400(resp) self.assertEqual( '"Invalid value for attribute kind. ' 'Expected options are `URL`, `FILE`"', resp.data)
def setup_evidence(self, source_gdrive_id, user_id): """Generate Evidence File object""" parent = self.row_converter.obj evidence = all_models.Evidence(title=source_gdrive_id, modified_by_id=user_id, context=parent.context, kind=self.KIND, source_gdrive_id=source_gdrive_id, parent_obj={ 'id': parent.id, 'type': parent.__class__.__name__ }) evidence.add_admin_role() rel_obj = all_models.Relationship( source=all_models.Assessment.query.get(parent.id), destination=evidence) signals.Restful.model_posted.send(rel_obj.__class__, obj=rel_obj)