Ejemplo n.º 1
0
def test_list_purchases_date_limit(
    mock_list_purchases_date_limit, mock_create_connection,
    mock_os_path_expanduser
):
    g = Groc()
    g.list_purchases_date_limit('01', '2019', 20)
    mock_list_purchases_date_limit.assert_called_with(
        'some-connection', '01', '2019', 20)
Ejemplo n.º 2
0
def test_list_month_year_limit_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 limit by 1
    month, year, limit = '01', '2019', 1
    purchases = g.list_purchases_date_limit(month, year, limit)
    table = from_db_cursor(purchases)
    table.title = f'Last {limit} purchase(s) 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', '-l', 1, '--verbose'])
    assert result.exit_code == 0
    assert result.output == f'{table.get_string()}\n'