# Path: pynYNAB/Client.py
# class nYnabClient(object):
#     def __new__(cls, *args, **kwargs):
#         connection = kwargs.pop('nynabconnection', None)
#         email = connection.email if hasattr(connection, 'email')\
#             else kwargs.pop('email', '')
#         password = connection.password if hasattr(connection, 'password')\
#             else kwargs.pop('password', '')
#         budget_name = kwargs.pop('budgetname', None)
# 
#         factory = nYnabClientFactory()
#         return factory.create_client(email, password, budget_name, connection)
# 
# Path: pynYNAB/exceptions.py
# class NoBudgetNameException(ValueError):
#     def __init__(self):
#         super(NoBudgetNameException,self).__init__('you should pass a budget_name ')
# 
# Path: pynYNAB/schema/catalog.py
# class BudgetVersion(Base, CatalogEntity):
#     date_format = Column(String)
#     last_accessed_on = Column(String)
#     currency_format = Column(String)
#     budget_id = Column(ForeignKey('catalogbudget.id'))
#     budget = relationship('CatalogBudget', foreign_keys=budget_id)
#     version_name = Column(String)
#     source = Column(String)


import json
import pytest
from pynYNAB.Client import nYnabClient
from pynYNAB.ClientFactory import nYnabClientFactory
from pynYNAB.exceptions import NoBudgetNameException
from pynYNAB.schema.catalog import BudgetVersion
        currency_symbol='$',
        display_symbol=True
    )
    date_format = dict(
        format='MM/DD/YYYY'
    )

    class MockConnection(object):
        def dorequest(this, request_dic, opname):
            assert opname == opname
            assert request_dic['currency_format'] == json.dumps(currency_format)
            assert request_dic['date_format'] == json.dumps(date_format)

        user_id = '1234'
        id = '1234'

    client = factory.create_client(budget_name='budget_name', connection=MockConnection(), sync=False)

    client.create_budget(budget_name='New Budget')


def test_client_nobudget():
    def create_client_no_budget():
        nYnabClient()

    pytest.raises(NoBudgetNameException, create_client_no_budget)


def test_select_budget(client):
    budget_version1 = BudgetVersion(version_name='TestBudget')

# Path: pynYNAB/Client.py
# class nYnabClient(object):
#     def __new__(cls, *args, **kwargs):
#         connection = kwargs.pop('nynabconnection', None)
#         email = connection.email if hasattr(connection, 'email')\
#             else kwargs.pop('email', '')
#         password = connection.password if hasattr(connection, 'password')\
#             else kwargs.pop('password', '')
#         budget_name = kwargs.pop('budgetname', None)
# 
#         factory = nYnabClientFactory()
#         return factory.create_client(email, password, budget_name, connection)
# 
# Path: pynYNAB/exceptions.py
# class NoBudgetNameException(ValueError):
#     def __init__(self):
#         super(NoBudgetNameException,self).__init__('you should pass a budget_name ')
# 
# Path: pynYNAB/schema/catalog.py
# class BudgetVersion(Base, CatalogEntity):
#     date_format = Column(String)
#     last_accessed_on = Column(String)
#     currency_format = Column(String)
#     budget_id = Column(ForeignKey('catalogbudget.id'))
#     budget = relationship('CatalogBudget', foreign_keys=budget_id)
#     version_name = Column(String)
#     source = Column(String)


# Path: tests/test_operations.py
import json
import pytest
from pynYNAB.Client import nYnabClient
from pynYNAB.ClientFactory import nYnabClientFactory
from pynYNAB.exceptions import NoBudgetNameException
from pynYNAB.schema.catalog import BudgetVersion

        currency_symbol='$',
        display_symbol=True
    )
    date_format = dict(
        format='MM/DD/YYYY'
    )

    class MockConnection(object):
        def dorequest(this, request_dic, opname):
            assert opname == opname
            assert request_dic['currency_format'] == json.dumps(currency_format)
            assert request_dic['date_format'] == json.dumps(date_format)

        user_id = '1234'
        id = '1234'

    client = factory.create_client(budget_name='budget_name', connection=MockConnection(), sync=False)

    client.create_budget(budget_name='New Budget')


def test_client_nobudget():
    def create_client_no_budget():
        nYnabClient()

    pytest.raises(NoBudgetNameException, create_client_no_budget)


def test_select_budget(client):
    budget_version1 = BudgetVersion(version_name='TestBudget')

    budget_version2 = BudgetVersion(version_name='NewTestBudget')