Example #1
0
    def test_load_image_metadata_not_found(self):
        """Unit test for method load_image_metadata, index not found case."""
        with self.assertRaises(IndexError):
            image_database = ImageDatabase(
                import_images=True,
                directory=TEST_DIRECTORY
            )

            _ = image_database.load_image_metadata(999)
Example #2
0
def test_load_image_metadata_filtered():
    """Unit test for method load_image_metadata, filtered input case."""
    image_database = ImageDatabase(
        import_images=True,
        data_dir=TEST_DIRECTORY
    )

    test_filter = ('id', 'original_file_size')

    test_metadata = image_database.load_image_metadata(0, filtered=test_filter)

    for key in test_metadata:
        assert key in test_filter
Example #3
0
def test_load_image_metadata():
    """Unit test for method load_image_metadata."""
    image_database = ImageDatabase(
        import_images=True,
        data_dir=TEST_DIRECTORY
    )

    test_metadata = image_database.load_image_metadata(0)

    del test_metadata['original_access_time']

    test_metadata = resolve_original_path(test_metadata)

    assert test_metadata == TEST_METADATA

    test_metadata = image_database.load_image_metadata(1)

    del test_metadata['original_access_time']

    test_metadata = resolve_original_path(test_metadata)

    assert test_metadata == TEST_METADATA_HTTP
Example #4
0
def test_save_image_metadata():
    """Unit test for method save_image_metadata."""
    image_database = ImageDatabase(
        import_images=True,
        data_dir=TEST_DIRECTORY
    )

    image_database.save_image_metadata(0, TEST_IMAGE)

    test_metadata = image_database.load_image_metadata(0)

    del test_metadata['original_access_time']

    test_metadata['original_path'] = relpath(test_metadata['original_path'])

    assert test_metadata == TEST_METADATA