Exemplo n.º 1
0
 def test_feature_error(self, mock_logger):
     """
     Checks code execution on error
     """
     invalid_features = ["some_invalid_feature"]
     MetadataExtractor.get_tuples(self.test_valid_plan, invalid_features)
     MetadataExtractor.logging.debug.assert_called_once()
Exemplo n.º 2
0
 def test_success(self, features_lists):
     for features in features_lists:
         tuple_list = MetadataExtractor.get_tuples(
             self.test_valid_plan, features)
         dict_fields = MetadataExtractor.get_dict_fields(
             dict(tuple_list), features)
         assert dict_fields[tuple_list[0][0]] == tuple_list[0][1]
Exemplo n.º 3
0
 def test_thread_start_success(self, mocker):
     """
     Checks whether the stub function is called on thread start
     """
     stub = mocker.stub(name='job_func_stub')
     MetadataExtractor.run_threaded(stub)
     stub.assert_called_once()
Exemplo n.º 4
0
    def test_conn_reset_error(self, mock_shutil):

        mock_shutil.rmtree.side_effect = ConnectionResetError

        MetadataExtractor.clear_storage()
        MetadataExtractor.logging.debug.assert_any_call(
            'The connection was reset during the deletion')
Exemplo n.º 5
0
 def test_success(self):
     MetadataExtractor.clear_storage()
     MetadataExtractor.logging.debug.assert_any_call(
         'Deleted: %s %s %s %s', str(1),
         ' out of ',
         str(len(self.processed_series_but_yet_to_delete)),
         ' remaining extraction completed series.'
     )
Exemplo n.º 6
0
    def test_os_error(self, mock_shutil):

        mock_shutil.rmtree.side_effect = OSError

        MetadataExtractor.clear_storage()
        MetadataExtractor.logging.debug.assert_any_call(
            'New images arriving for the series. Therefore, do not delete the series: %s',
            self.processed_series_but_yet_to_delete[0]
        )
Exemplo n.º 7
0
    def test_file_not_found_error(self, mock_shutil):

        mock_shutil.rmtree.side_effect = FileNotFoundError

        MetadataExtractor.clear_storage()
        MetadataExtractor.logging.debug.assert_any_call(
            'The series of id %s was not found. Hence, not deleted in this iteration. Probably it was already deleted in a previous iteration without being tracked or by an external process',
            self.processed_series_but_yet_to_delete[0]
        )
Exemplo n.º 8
0
 def test_success(self, features_lists):
     """
     Cross checks key between return values of get_tuples and get_dict_fields
     """
     for features in features_lists:
         tuple_list = MetadataExtractor.get_tuples(
             self.test_valid_plan, features)
         dict_fields = MetadataExtractor.get_dict_fields(
             dict(tuple_list), features)
         assert dict_fields[tuple_list[0][0]] == tuple_list[0][1]
Exemplo n.º 9
0
 def test_update_success(self, mocker, mock_logger, mock_global_config):
     mocker.patch.multiple(
         MetadataExtractor,
         processed_series_but_yet_to_delete=self.processed_series_but_yet_to_delete,
         processed_and_deleted_series=self.processed_and_deleted_series,
     )
     # Function Completes write without error
     MetadataExtractor.update_pickle()
     MetadataExtractor.logging.debug.assert_called_once_with(
         'dumping complete')
Exemplo n.º 10
0
 def test_correct_output_with_key(self, features_lists):
     key = "rand_key"
     for features in features_lists:
         first_key = key + "_" + features[0]
         tuple_list = MetadataExtractor.get_tuples(
             self.test_valid_plan, features, key=key)
         assert tuple_list[0][0] == first_key
Exemplo n.º 11
0
 def test_correct_output(self, features_lists):
     """
     Checks one of the returned keys is a part of defined feature list
     """
     for features in features_lists:
         tuple_list = MetadataExtractor.get_tuples(
             self.test_valid_plan, features)
         assert tuple_list[0][0] in features
Exemplo n.º 12
0
 def test_correct_output_with_key(self, features_lists):
     """
     Checks one of the returned keys (with key prefix) is a part of defined feature list
     """
     key = "rand_key"
     for features in features_lists:
         tuple_list = MetadataExtractor.get_tuples(
             self.test_valid_plan, features, key=key)
         assert tuple_list[0][0].split(key + "_")[-1] in features
Exemplo n.º 13
0
 def test_measure_diskutil(self, mock_logger, mock_global_config):
     """
     Check for code execution not raising error.
     """
     MetadataExtractor.measure_diskutil()
     MetadataExtractor.logging.info.assert_called_once()
Exemplo n.º 14
0
 def test_correct_output(self, features_lists):
     for features in features_lists:
         first_key = features[0]
         tuple_list = MetadataExtractor.get_tuples(
             self.test_valid_plan, features)
         assert tuple_list[0][0] == first_key
Exemplo n.º 15
0
 def test_thread_start_success(self, mocker):
     stub = mocker.stub(name='job_func_stub')
     MetadataExtractor.run_threaded(stub)
     stub.assert_called_once()
Exemplo n.º 16
0
 def test_measure_diskutil(self, mock_logger, mock_global_config):
     MetadataExtractor.measure_diskutil()
     MetadataExtractor.logging.info.assert_called_once()