Esempio n. 1
0
def test_update_value():
    key_val = random_utilities.random_string()
    numeric_val = random_utilities.random_double()
    row = {key_column: key_val, numeric_column: numeric_val}
    table.insert_row(row)
    new_val = random_utilities.random_double()
    assert table.update_value(key_column, key_val, numeric_column,
                              new_val) is True
    assert table.get_float_value(key_column, key_val,
                                 numeric_column) == new_val
Esempio n. 2
0
def test_update_average_price():
    average_price = random_utilities.random_double()
    yearly_history_table.update_average_price(test_ticker, test_year,
                                              average_price)
    retrieved_average_price = yearly_history_table.get_average_price(
        test_ticker, test_year)
    assert retrieved_average_price == average_price
Esempio n. 3
0
def test_get_float_value():
    key_val = random_utilities.random_string()
    numeric_val = random_utilities.random_double()
    row = {key_column: key_val, numeric_column: numeric_val}
    table.insert_row(row)
    assert table.get_float_value(key_column, key_val,
                                 numeric_column) == numeric_val
def test_upsert_1row():
    rows = [_random_row()]

    retrieved_rows = daily_history_table.get_history(rows[0]['ticker'])
    assert len(retrieved_rows) == 0

    assert daily_history_table.upsert(rows) is True
    retrieved_row = daily_history_table.get_history(rows[0]['ticker'])[0]
    assert float(retrieved_row['dividend']) == rows[0]['dividend']

    rows[0]['dividend'] = random_utilities.random_double()
    assert daily_history_table.upsert(rows) is True
    retrieved_row = daily_history_table.get_history(rows[0]['ticker'])[0]
    assert float(retrieved_row['dividend']) == rows[0]['dividend']
def _random_row(ticker=None):
    if ticker is None:
        ticker = random_utilities.random_letters()
    return {
        'ticker': ticker,
        'date': random_utilities.random_date(),
        'open': random_utilities.random_double(),
        'high': random_utilities.random_double(),
        'low': random_utilities.random_double(),
        'close': random_utilities.random_double(),
        'adjusted_close': random_utilities.random_double(),
        'volume': random_utilities.random_int(0, 10000000),
        'dividend': random_utilities.random_double(),
        'split_coefficient': 1.000
    }
Esempio n. 6
0
def test_update_row_numeric(cursor):
    new_value = random_utilities.random_double()
    assert postgres.update_value(cursor, test_table_name, 'id', test_table_row_id, 'numeric_col', new_value) is True
Esempio n. 7
0
def test_update_dividend_yield():
    dividend_yield = random_utilities.random_double()
    yearly_history_table.update_dividend_yield(test_ticker, test_year,
                                               dividend_yield)
Esempio n. 8
0
def test_update_dividend():
    dividend = random_utilities.random_double()
    yearly_history_table.update_dividend(test_ticker, test_year, dividend)
    retrieved_dividend = yearly_history_table.get_dividend(
        test_ticker, test_year)
    assert retrieved_dividend == dividend
Esempio n. 9
0
def test_update_end_price():
    end_price = random_utilities.random_double()
    assert yearly_history_table.update_end_price(test_ticker, test_year,
                                                 end_price) is True