예제 #1
0
def test_data_import_cointracking(rotkehlchen_api_server, file_upload):
    """Test that the data import endpoint works successfully for cointracking

    To test that data import works both with specifying filepath and uploading
    the file try both ways in this test.
    """
    rotki = rotkehlchen_api_server.rest_api.rotkehlchen
    dir_path = Path(
        os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
    filepath = dir_path / 'data' / 'cointracking_trades_list.csv'

    if file_upload:
        files = {'file': open(filepath, 'rb')}
        response = requests.post(
            api_url_for(
                rotkehlchen_api_server,
                'dataimportresource',
            ),
            files=files,
            data={'source': 'cointracking.info'},
        )
    else:
        json_data = {'source': 'cointracking.info', 'file': str(filepath)}
        response = requests.put(
            api_url_for(
                rotkehlchen_api_server,
                'dataimportresource',
            ),
            json=json_data,
        )

    result = assert_proper_response_with_result(response)
    assert result is True
    # And also assert data was imported succesfully
    assert_cointracking_import_results(rotki)
예제 #2
0
def test_data_import_cointracking(rotkehlchen_api_server):
    """Test that the data import endpoint works successfully for cointracking"""
    rotki = rotkehlchen_api_server.rest_api.rotkehlchen
    dir_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
    filepath = os.path.join(dir_path, 'data', 'cointracking_trades_list.csv')

    json_data = {'source': 'cointracking.info', 'filepath': filepath}
    response = requests.put(
        api_url_for(
            rotkehlchen_api_server,
            "dataimportresource",
        ), json=json_data,
    )
    assert_proper_response(response)
    data = response.json()
    assert data['message'] == ''
    assert data['result'] is True
    # And also assert data was imported succesfully
    assert_cointracking_import_results(rotki)