Example #1
0
def test_download_cached(exists_mock, read_csv_mock):
    # setup
    exists_mock.return_value = True

    # run
    returned = download('a_signal_name')

    # assert
    assert returned == read_csv_mock.return_value

    expected_filename = os.path.join(DATA_PATH, 'a_signal_name.csv')
    read_csv_mock.assert_called_once_with(expected_filename)
Example #2
0
def test_download_new(exists_mock, read_csv_mock):
    # setup
    exists_mock.return_value = False

    # run
    returned = download('a_signal_name')

    # assert
    assert returned == read_csv_mock.return_value

    expected_url = 'https://d3-ai-orion.s3.amazonaws.com/a_signal_name.csv'
    read_csv_mock.assert_called_once_with(expected_url)

    expected_filename = os.path.join(DATA_PATH, 'a_signal_name.csv')
    returned.to_csv.assert_called_once_with(expected_filename, index=False)