Esempio n. 1
0
def test_obtain_cluster_segment_hash_results_invalid_number_of_hashes():
    client = Client()
    response = {'client_id': client._client_id, 'hashes': ['test']}

    client.get_cluster_response = MagicMock(return_value=response)

    with pytest.raises(ValueError):
        client.obtain_cluster_segment_hash_results()
Esempio n. 2
0
def test_obtain_cluster_segment_hash_results_missing_key(key):
    client = Client()
    response = {'client_id': client._client_id, 'hashes': ['test']}

    del response[key]
    client.get_cluster_response = MagicMock(return_value=response)

    with pytest.raises(KeyError):
        client.obtain_cluster_segment_hash_results()
Esempio n. 3
0
def test_obtain_cluster_segment_hash_results_valid():
    client = Client()
    hash_data = {key: 'test' for key in range(NUMBER_OF_DATASET_SEGMENTS)}
    response = {'client_id': client._client_id, 'hashes': hash_data.keys()}

    hash_data = {key: 'test' for key in range(NUMBER_OF_DATASET_SEGMENTS)}
    client._dataset_segments = hash_data

    client.get_cluster_response = MagicMock(return_value=response)

    client.obtain_cluster_segment_hash_results()
Esempio n. 4
0
def test_get_cluster_task_id_invalid_signature():
    client = Client()
    response = {
        'client_id': 'test',
        'task_id': 'test',
        'cluster_response_address': 'test'
    }

    client.get_cluster_response = MagicMock(return_value=response)

    with pytest.raises(ValueError):
        client.obtain_cluster_task_id()
Esempio n. 5
0
def test_get_cluster_task_id_attributes_properly_set():
    client = Client()
    response = {
        'client_id': client._client_id,
        'task_id': 'test',
        'cluster_response_address': 'test_adress'
    }

    client.get_cluster_response = MagicMock(return_value=response)
    client.obtain_cluster_task_id()

    assert client._task_id == response['task_id']
    assert client._cluster_address == response['cluster_response_address']
Esempio n. 6
0
def test_get_cluster_task_id_invalid_response_structure(key):
    client = Client()
    response = {
        'client_id': client._client_id,
        'task_id': 'test',
        'cluster_response_address': 'test'
    }

    del response[key]
    client.get_cluster_response = MagicMock(return_value=response)

    with pytest.raises(KeyError):
        client.obtain_cluster_task_id()
Esempio n. 7
0
def test_get_cluster_task_id_invalid_response_type(cluster_response):
    client = Client()
    client.get_cluster_response = MagicMock(return_value=cluster_response)

    with pytest.raises(TypeError):
        client.obtain_cluster_task_id()