# Path: pynYNAB/schema/budget.py
# class SubCategory(Base, BudgetEntity):
#     entities_account_id = Column(ForeignKey('account.id'))
#     entities_account = relationship('Account', foreign_keys=entities_account_id)
#     entities_master_category_id = Column(ForeignKey('mastercategory.id'))
#     entities_master_category = relationship('MasterCategory', foreign_keys=entities_master_category_id)
#     goal_creation_month = Column(String)
#     goal_type = Column(String)
#     internal_name = Column(String)
#     is_hidden = Column(Boolean, default=False)
#     monthly_funding = Column(String)
#     name = Column(String)
#     note = Column(String)
#     sortable_index = Column(Integer, default=0)
#     target_balance = Column(AmountType)
#     target_balance_month = Column(String)
#     type = Column(String)
# 
# class Payee(Base, BudgetEntity):
#     auto_fill_amount = Column(AmountType)
#     auto_fill_amount_enabled = Column(String)
#     auto_fill_memo = Column(String)
#     auto_fill_memo_enabled = Column(String)
#     auto_fill_subcategory_enabled = Column(String)
#     auto_fill_subcategory_id = Column(ForeignKey('subcategory.id'))
#     auto_fill_subcategory = relationship('SubCategory', foreign_keys=auto_fill_subcategory_id)
#     enabled = Column(Boolean, default=True)
#     entities_account_id = Column(ForeignKey('account.id'))
#     entities_account = relationship('Account', foreign_keys=entities_account_id)
#     internal_name = Column(String)
#     name = Column(String)
#     rename_on_import_enabled = Column(String)
# 
# class MasterCategory(Base, BudgetEntity):
#     deletable = Column(Boolean, default=True)
#     internal_name = Column(String)
#     is_hidden = Column(Boolean, default=False)
#     name = Column(String)
#     note = Column(String)
#     sortable_index = Column(String)
# 
# 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: pynYNAB/schema/roots.py
# class Catalog(Base, RootEntity):
#     ce_user_budgets = relationship('UserBudget')
#     ce_user_settings = relationship('UserSetting')
#     ce_budget_versions = relationship('BudgetVersion')
#     ce_users = relationship('User')
#     ce_budgets = relationship('CatalogBudget')
# 
# class Budget(Base, RootEntity):
#     be_transactions = relationship('Transaction')
#     be_master_categories = relationship('MasterCategory')
#     be_settings = relationship('Setting')
#     be_monthly_budget_calculations = relationship('MonthlyBudgetCalculation')
#     be_account_mappings = relationship('AccountMapping')
#     be_subtransactions = relationship('Subtransaction')
#     be_scheduled_subtransactions = relationship('ScheduledSubtransaction')
#     be_monthly_budgets = relationship('MonthlyBudget')
#     be_subcategories = relationship('SubCategory')
#     be_payee_locations = relationship('PayeeLocation')
#     be_account_calculations = relationship('AccountCalculation')
#     be_monthly_account_calculations = relationship('MonthlyAccountCalculation')
#     be_monthly_subcategory_budget_calculations = relationship('MonthlySubcategoryBudgetCalculation')
#     be_scheduled_transactions = relationship('ScheduledTransaction')
#     be_payees = relationship('Payee')
#     be_monthly_subcategory_budgets = relationship('MonthlySubcategoryBudget')
#     be_payee_rename_conditions = relationship('PayeeRenameCondition')
#     be_accounts = relationship('Account')
#     last_month = Column(Date)
#     first_month = Column(Date)
# 
#     knowledge = relationship('Knowledge')


import pytest
from pynYNAB.ClientFactory import nYnabClientFactory
from pynYNAB.schema.budget import SubCategory, Payee, MasterCategory
from pynYNAB.schema.catalog import BudgetVersion
from pynYNAB.schema.roots import Catalog, Budget



class MockConnection(object):
    def __init__(self):
        self.id = '1234'
        self.user_id = '1234'
        self.catalog = Catalog()
        self.budget = Budget()

    def dorequest(self, request_dic, opname):
        if opname == 'syncCatalogData':
            return {'changed_entities': {k: [] for k in self.catalog.listfields}, 'server_knowledge_of_device': 0,
                    'current_server_knowledge': 123}
        if opname == 'syncBudgetData':

# Path: pynYNAB/schema/budget.py
# class SubCategory(Base, BudgetEntity):
#     entities_account_id = Column(ForeignKey('account.id'))
#     entities_account = relationship('Account', foreign_keys=entities_account_id)
#     entities_master_category_id = Column(ForeignKey('mastercategory.id'))
#     entities_master_category = relationship('MasterCategory', foreign_keys=entities_master_category_id)
#     goal_creation_month = Column(String)
#     goal_type = Column(String)
#     internal_name = Column(String)
#     is_hidden = Column(Boolean, default=False)
#     monthly_funding = Column(String)
#     name = Column(String)
#     note = Column(String)
#     sortable_index = Column(Integer, default=0)
#     target_balance = Column(AmountType)
#     target_balance_month = Column(String)
#     type = Column(String)
# 
# class Payee(Base, BudgetEntity):
#     auto_fill_amount = Column(AmountType)
#     auto_fill_amount_enabled = Column(String)
#     auto_fill_memo = Column(String)
#     auto_fill_memo_enabled = Column(String)
#     auto_fill_subcategory_enabled = Column(String)
#     auto_fill_subcategory_id = Column(ForeignKey('subcategory.id'))
#     auto_fill_subcategory = relationship('SubCategory', foreign_keys=auto_fill_subcategory_id)
#     enabled = Column(Boolean, default=True)
#     entities_account_id = Column(ForeignKey('account.id'))
#     entities_account = relationship('Account', foreign_keys=entities_account_id)
#     internal_name = Column(String)
#     name = Column(String)
#     rename_on_import_enabled = Column(String)
# 
# class MasterCategory(Base, BudgetEntity):
#     deletable = Column(Boolean, default=True)
#     internal_name = Column(String)
#     is_hidden = Column(Boolean, default=False)
#     name = Column(String)
#     note = Column(String)
#     sortable_index = Column(String)
# 
# 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: pynYNAB/schema/roots.py
# class Catalog(Base, RootEntity):
#     ce_user_budgets = relationship('UserBudget')
#     ce_user_settings = relationship('UserSetting')
#     ce_budget_versions = relationship('BudgetVersion')
#     ce_users = relationship('User')
#     ce_budgets = relationship('CatalogBudget')
# 
# class Budget(Base, RootEntity):
#     be_transactions = relationship('Transaction')
#     be_master_categories = relationship('MasterCategory')
#     be_settings = relationship('Setting')
#     be_monthly_budget_calculations = relationship('MonthlyBudgetCalculation')
#     be_account_mappings = relationship('AccountMapping')
#     be_subtransactions = relationship('Subtransaction')
#     be_scheduled_subtransactions = relationship('ScheduledSubtransaction')
#     be_monthly_budgets = relationship('MonthlyBudget')
#     be_subcategories = relationship('SubCategory')
#     be_payee_locations = relationship('PayeeLocation')
#     be_account_calculations = relationship('AccountCalculation')
#     be_monthly_account_calculations = relationship('MonthlyAccountCalculation')
#     be_monthly_subcategory_budget_calculations = relationship('MonthlySubcategoryBudgetCalculation')
#     be_scheduled_transactions = relationship('ScheduledTransaction')
#     be_payees = relationship('Payee')
#     be_monthly_subcategory_budgets = relationship('MonthlySubcategoryBudget')
#     be_payee_rename_conditions = relationship('PayeeRenameCondition')
#     be_accounts = relationship('Account')
#     last_month = Column(Date)
#     first_month = Column(Date)
# 
#     knowledge = relationship('Knowledge')


# Path: tests/common_mock.py
import pytest
from pynYNAB.ClientFactory import nYnabClientFactory
from pynYNAB.schema.budget import SubCategory, Payee, MasterCategory
from pynYNAB.schema.catalog import BudgetVersion
from pynYNAB.schema.roots import Catalog, Budget




class MockConnection(object):
    def __init__(self):
        self.id = '1234'
        self.user_id = '1234'
        self.catalog = Catalog()
        self.budget = Budget()

    def dorequest(self, request_dic, opname):
        if opname == 'syncCatalogData':
            return {'changed_entities': {k: [] for k in self.catalog.listfields}, 'server_knowledge_of_device': 0,
                    'current_server_knowledge': 123}
        if opname == 'syncBudgetData':

            return {'changed_entities': {k: [] for k in self.budget.listfields}, 'server_knowledge_of_device': 0,