Пример #1
0
def test_get_file(populated_housekeeper_api: HousekeeperAPI):
    """Test to fetch a file from the database"""
    # GIVEN a housekeeper api with a file
    file_obj = populated_housekeeper_api.files().first()
    assert file_obj

    # GIVEN the id of a file that exists in HK
    file_id = file_obj.id

    # WHEN fetching the file with get_file
    hk_file = populated_housekeeper_api.get_file(file_id)

    # THEN assert a file was returned
    assert hk_file is not None
Пример #2
0
def test_delete_file(populated_housekeeper_api: HousekeeperAPI):
    """Test to fetch a file from the database"""
    # GIVEN a housekeeper api with a file
    file_obj = populated_housekeeper_api.files().first()
    assert file_obj

    # GIVEN the id of a file that exists in HK
    file_id = file_obj.id

    # WHEN deleting the file
    populated_housekeeper_api.delete_file(file_id)

    # THEN assert a file was removed
    assert populated_housekeeper_api.get_file(file_id) is None
Пример #3
0
def test_get_tag_names_from_file(populated_housekeeper_api: HousekeeperAPI):
    """Test get tag names on a file"""
    # GIVEN a housekeeper api with a file
    file_obj = populated_housekeeper_api.files().first()
    assert file_obj.tags

    # WHEN fetching tags of a file
    tag_names = populated_housekeeper_api.get_tag_names_from_file(file_obj)

    # THEN a list of tag names is returned
    assert tag_names is not None
    # THEN the return type is a list of strings
    assert isinstance(tag_names, list)
    assert all(isinstance(elem, str) for elem in tag_names)