Ejemplo n.º 1
0
def test_get_metadata(cbcloud_api_mock, hashes):
    """Unit test get_metadata function."""
    cbcloud_api_mock.mock_request("POST", "/ubs/v1/orgs/test/file/_download",
                                  FILE_DOWNLOAD_RESP)
    found_hashes = download_hashes(cbcloud_api_mock.api, hashes)
    cbcloud_api_mock.mock_request(
        "GET",
        f"/ubs/v1/orgs/test/sha256/{found_hashes[0]['sha256']}/metadata",
        METADATA_DOWNLOAD_RESP[found_hashes[0]['sha256']])
    metadata = get_metadata(cbcloud_api_mock.api, found_hashes[0])
    assert isinstance(metadata, dict)
    for key in METADATA_VALID.keys():
        assert key in metadata
    for key in metadata.keys():
        assert key in METADATA_VALID
Ejemplo n.º 2
0
def test_download_hashes_invalid(cbcloud_api_mock, input):
    """Unit test _download_hashes function with empty input."""
    cbcloud_api_mock.mock_request("POST", "/ubs/v1/orgs/test/file/_download",
                                  None)
    found_hashes = download_hashes(cbcloud_api_mock.api, input)
    assert found_hashes == []