def test_generate_upload_queue_args_tile_job(self): """Ensure ingest_type set properly""" ingest_mgmr = IngestManager() ingest_mgmr.validate_config_file(self.example_config_data) ingest_mgmr.validate_properties() ingest_mgmr.owner = self.user.pk job = ingest_mgmr.create_ingest_job() actual = ingest_mgmr._generate_upload_queue_args(job) assert actual['ingest_type'] == IngestJob.TILE_INGEST assert actual['z_chunk_size'] == 16
def test_generate_upload_queue_args_volumetric_job(self): """Ensure ingest_type set properly""" ingest_mgmr = IngestManager() ingest_mgmr.validate_config_file(self.volumetric_config_data) ingest_mgmr.validate_properties() ingest_mgmr.owner = self.user.pk job = ingest_mgmr.create_ingest_job() actual = ingest_mgmr._generate_upload_queue_args(job) assert actual['ingest_type'] == IngestJob.VOLUMETRIC_INGEST assert actual['z_chunk_size'] == 64 assert actual['ingest_queue'] is None
class BossIngestManagerTest(APITestCase): def setUp(self): """ Initialize the database :return: """ dbsetup = SetupTestDB() self.user = dbsetup.create_super_user(username='******', email='*****@*****.**', password='******') dbsetup.set_user(self.user) self.client.force_login(self.user) dbsetup.insert_ingest_test_data() setup = SetupTests() # Get the config_data for v1 schema config_data = setup.get_ingest_config_data_dict() self.example_config_data = config_data self.volumetric_config_data = setup.get_ingest_config_data_dict_volumetric() # Unit under test. self.ingest_mgr = IngestManager() def test_validate_ingest(self): """Method to test validation method""" #Validate schema and config file response = self.ingest_mgr.validate_config_file(self.example_config_data) assert (response is True) #Validate properties response = self.ingest_mgr.validate_properties() assert (response is True) def test_validate_config_file(self): """Method to test validation of a config file""" self.ingest_mgr.validate_config_file(self.example_config_data) assert(self.ingest_mgr.config is not None) assert (self.ingest_mgr.config.config_data is not None) def test_validate_properties(self): """Methos to test validation of properties of the config data""" self.ingest_mgr.validate_config_file(self.example_config_data) self.ingest_mgr.validate_properties() assert (self.ingest_mgr.collection.name == 'my_col_1') assert (self.ingest_mgr.experiment.name == 'my_exp_1') assert (self.ingest_mgr.channel.name == 'my_ch_1') def test_create_ingest_job(self): """Method to test creation of a ingest job from a config_data dict""" self.ingest_mgr.validate_config_file(self.example_config_data) self.ingest_mgr.validate_properties() self.ingest_mgr.owner = self.user.pk job = self.ingest_mgr.create_ingest_job() assert (job.id is not None) assert (job.ingest_type == IngestJob.TILE_INGEST) assert (job.tile_size_x == 512) assert (job.tile_size_y == 512) assert (job.tile_size_z == 1) assert (job.tile_size_t == 1) def test_create_ingest_job_volumetric(self): self.ingest_mgr.validate_config_file(self.volumetric_config_data) self.ingest_mgr.validate_properties() self.ingest_mgr.owner = self.user.pk job = self.ingest_mgr.create_ingest_job() assert (job.id is not None) assert (job.ingest_type == IngestJob.VOLUMETRIC_INGEST) assert (job.tile_size_x == 1024) assert (job.tile_size_y == 1024) assert (job.tile_size_z == 64) assert (job.tile_size_t == 1) def test_generate_upload_queue_args_tile_job(self): """Ensure ingest_type set properly""" self.ingest_mgr.validate_config_file(self.example_config_data) self.ingest_mgr.validate_properties() self.ingest_mgr.owner = self.user.pk job = self.ingest_mgr.create_ingest_job() actual = self.ingest_mgr._generate_upload_queue_args(job) assert actual['ingest_type'] == IngestJob.TILE_INGEST assert actual['z_chunk_size'] == 16 def test_generate_upload_queue_args_volumetric_job(self): """Ensure ingest_type set properly""" self.ingest_mgr.validate_config_file(self.volumetric_config_data) self.ingest_mgr.validate_properties() self.ingest_mgr.owner = self.user.pk job = self.ingest_mgr.create_ingest_job() actual = self.ingest_mgr._generate_upload_queue_args(job) assert actual['ingest_type'] == IngestJob.VOLUMETRIC_INGEST assert actual['z_chunk_size'] == 64 assert actual['ingest_queue'] is None def test_tile_bucket_name(self): """ Test get tile bucket name""" tile_bucket_name = self.ingest_mgr.get_tile_bucket() assert(tile_bucket_name is not None) def test_get_resource_data(self): """Run the method and ensure keys set""" self.ingest_mgr.validate_config_file(self.example_config_data) self.ingest_mgr.validate_properties() self.ingest_mgr.owner = self.user.pk job = self.ingest_mgr.create_ingest_job() actual = self.ingest_mgr.get_resource_data(job.id) self.assertIn('boss_key', actual) self.assertIn('lookup_key', actual) self.assertIn('channel', actual) self.assertIn('experiment', actual) self.assertIn('coord_frame', actual)