Esempio n. 1
0
def test_list_purchases_date(
    mock_list_purchases_date, mock_create_connection, mock_os_path_expanduser
):
    g = Groc()
    g.list_purchases_date('01', '2019')
    mock_list_purchases_date.assert_called_with(
        'some-connection', '01', '2019')
Esempio n. 2
0
def test_list_month_year_all_verbose(groc_connection, groc_db_url,
                                     connection_function_scope,
                                     stores_and_purchases_function_scope):

    groc_connection.return_value = connection_function_scope
    g = Groc()

    # Make table for Jan 2019 purchases (3 total)
    month, year = '01', '2019'
    purchases = g.list_purchases_date(month, year)
    table = from_db_cursor(purchases)
    table.title = f'All purchases from {month}/{year}'
    table.align['store'] = 'r'
    table.align['total'] = 'r'
    table.align['description'] = 'l'

    runner = CliRunner()
    result = runner.invoke(
        groc_cli, ['list', '-m', '01', '-y', '2019', '--all', '--verbose'])
    assert result.exit_code == 0
    assert result.output == f'{table.get_string()}\n'