Ejemplo n.º 1
0
def test_data_stats_endpoint_without_price(client):
    response = client.get('/cbeci/api/data/stats/')  # type: Response

    assert response_is_successful(response)
    assert b"Welcome to the CBECI API data endpoint. " \
        b"To get bitcoin electricity consumption estimate timeseries, " \
        b"specify electricity price parameter 'p' (in USD), for example /api/data/stats/?p=0.05" == response.data
Ejemplo n.º 2
0
def test_data_monthly_endpoint_price_path(client):
    response = client.get('/cbeci/api/data/monthly/0.05')  # type: Response

    assert response_is_successful(response)
    assert response_has_data_list(response)
    assert response_data_item_has_keys(
        response, ['month', 'timestamp', 'value', 'cumulative_value'])
Ejemplo n.º 3
0
def test_data_stats_endpoint_price_path(client):
    response = client.get('/cbeci/api/data/stats/0.05')  # type: Response

    assert response_is_successful(response)
    response_data = json.loads(response.data)
    assert item_has_keys(response_data, [
        'guess_consumption', 'guess_power', 'max_consumption', 'max_power',
        'min_consumption', 'min_power'
    ])
Ejemplo n.º 4
0
def test_data_endpoint_price_path(client):
    response = client.get('/cbeci/api/data/0.05')  # type: Response

    assert response_is_successful(response)
    assert response_has_data_list(response)
    assert response_data_item_has_keys(response, [
        'date', 'guess_consumption', 'max_consumption', 'min_consumption',
        'timestamp'
    ])
Ejemplo n.º 5
0
def test_download_endpoint_v1_1_1_download_monthly_data(client):
    response = client.get('/cbeci/api/v1.1.1/download/data/monthly')  # type: Response
    assert response_is_successful(response)
    assert response_is_csv(response)
    assert csv_has_headers(response, [
        'Month',
        'Monthly consumption, TWh',
        'Cumulative consumption, TWh',
    ], row_i=1)
Ejemplo n.º 6
0
def test_download_endpoint_v1_1_1_download_data(client):
    response = client.get('/cbeci/api/v1.1.1/download/data')  # type: Response
    assert response_is_successful(response)
    assert response_is_csv(response)
    assert csv_has_headers(response, [
        'Timestamp',
        'Date and Time',
        'power MAX, GW',
        'power MIN, GW',
        'power GUESS, GW',
        'annualised consumption MAX, TWh',
        'annualised consumption MIN, TWh',
        'annualised consumption GUESS, TWh',
    ], row_i=1)
Ejemplo n.º 7
0
def test_download_endpoint_text_pages(client):
    response = client.get('/cbeci/api/text_pages/')  # type: Response
    assert response_is_successful(response)
Ejemplo n.º 8
0
def test_download_endpoint_reports(client):
    response = client.get('/cbeci/api/reports/')  # type: Response
    assert response_is_successful(response)
Ejemplo n.º 9
0
def test_download_endpoint_v1_1_0_download_mining_countries(client):
    response = client.get('/cbeci/api/v1.1.0/download/mining_countries')  # type: Response
    assert response_is_successful(response)
    assert response_is_csv(response)
    assert csv_has_headers(response, ['Date', 'Country', 'Share of global hashrate'])
Ejemplo n.º 10
0
def test_download_endpoint_v1_1_0_download_data(client):
    response = client.get('/cbeci/api/v1.1.0/download/data')  # type: Response
    assert response_is_successful(response)
    assert response_is_csv(response)
    assert csv_has_headers(response, ['Timestamp', 'Date and Time', 'MIN', 'MAX', 'GUESS'], row_i=1)
Ejemplo n.º 11
0
def test_download_endpoint_v1_1_1_download_mining_provinces(client):
    response = client.get('/cbeci/api/v1.1.1/download/mining_provinces')  # type: Response
    assert response_is_successful(response)
    assert response_is_csv(response)
    assert csv_has_headers(response, ['Date', 'Province', 'Share of Chinese hashrate'])
Ejemplo n.º 12
0
def test_download_endpoint_v1_1_1_download_mining_countries(client):
    response = client.get('/cbeci/api/v1.1.1/download/mining_countries')  # type: Response
    assert response_is_successful(response)
    assert response_is_csv(response)
    assert csv_has_headers(response, ['date', 'country', 'monthly_hashrate_%', 'monthly_absolute_hashrate_EH/S'])
Ejemplo n.º 13
0
def test_charts_endpoint_mining_equipment_efficiency(client):
    response = client.get(
        '/cbeci/api/charts/mining_equipment_efficiency')  # type: Response
    assert response_is_successful(response)
    assert response_has_data_list(response)
    assert response_data_item_has_keys(response, ['name', 'x', 'y'])
Ejemplo n.º 14
0
def test_charts_endpoint_mining_map_countries(client):
    response = client.get(
        '/cbeci/api/charts/mining_map_countries')  # type: Response
    assert response_is_successful(response)
    assert response_has_data_list(response)
    assert response_data_item_has_keys(response, ['code', 'name', 'x', 'y'])
Ejemplo n.º 15
0
def test_charts_endpoint_profitability_threshold(client):
    response = client.get(
        '/cbeci/api/charts/profitability_threshold')  # type: Response
    assert response_is_successful(response)
    assert response_has_data_list(response)
    assert response_data_item_has_keys(response, ['x', 'y'])