def test_validate_config_json_provided(self): invalid_config_mapper = FieldMapper( config_json=json_string({"add_literals": "invalid value"})) self.assertIsNone( invalid_config_mapper.validate_config_json( json_string({"add_literals": { "foo": "bar" }})))
def setUpTestData(cls): cls.attributes = { 'name': 'Test Field Mapper', 'config_json': json_string({"add_literals": { "foo": "bar" }}), 'field_mapper_type': 'xml2kvp' } cls.field_mapper = FieldMapper(**cls.attributes)
def setUp(self): self.config = TestConfiguration() task_params_json = { "job_id": self.config.job.id, "record_group_id": self.config.record_group.id, "org_id": self.config.org.id } self.bg_task = CombineBackgroundTask.objects.create( celery_task_id='test celery id', task_type='job_reindex', task_params_json=json_string(task_params_json))
def test_get_bg_task_no_job(self): new_task_params = { "record_group_id": self.config.record_group.id, "org_id": self.config.org.id } new_task = CombineBackgroundTask.objects.create( celery_task_id='new celery id', task_type='export_documents', task_params_json=json_string(new_task_params)) response = self.client.get( f'/combine/background_tasks/task/{new_task.id}') self.assertIn(b'new celery id', response.content) self.assertIn(b'Download Documents as Archive', response.content)
def test_post_test_field_mapper(self): field_mapper = FieldMapper.objects.create( field_mapper_type='xml2kvp', config_json=json_string({"add_literals": { "foo": "bar" }}), name='test field mapper') response = self.client.post( reverse('test_field_mapper'), { 'db_id': self.config.record.id, 'fm_config_json': field_mapper.config_json }) self.assertEqual(response.json(), { 'root_foo': 'test document', 'foo': 'bar' })
def test_validate_config_json_invalid(self): invalid_config_mapper = FieldMapper( config_json=json_string({"add_literals": "invalid value"})) self.assertRaises(jsonschema.exceptions.ValidationError, invalid_config_mapper.validate_config_json)