def test_list_limit_more_than_100(groc_connection, groc_db_url, connection_function_scope, stores_and_purchases_function_scope): groc_connection.return_value = connection_function_scope g = Groc() # Make table table = from_db_cursor(g.list_purchases_limit(101)) table.title = f'Last 50 purchase(s)' table.align['store'] = 'r' table.align['total'] = 'r' table.align['description'] = 'l' runner = CliRunner() result = runner.invoke(groc_cli, ['list', '--verbose']) assert result.exit_code == 0 assert result.output == f'{table.get_string()}\n'
def test_list_limit_default_no_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 purchases = g.list_purchases_limit(50) table = from_db_cursor(purchases) table.title = f'Last 50 purchase(s)' table.align['store'] = 'r' table.align['total'] = 'r' table.align['description'] = 'l' field_names = [name for name in table.field_names] field_names.remove('id') runner = CliRunner() result = runner.invoke(groc_cli, ['list']) assert result.exit_code == 0 assert result.output == f'{table.get_string(fields=field_names)}\n'
def test_list_purchases_limit( mock_list_purchases_limit, mock_create_connection, mock_os_path_expanduser ): g = Groc() g.list_purchases_limit(20) mock_list_purchases_limit.assert_called_with('some-connection', 20)