Пример #1
0
 def test_typeOK_ynabsynccalled(self):
     data = {"transactions": [{}]}
     try:
         body, code = create_transactions_from_ofx(
             data, ynab_client=mockYnabClient)
     except KeyError:
         pass
     self.assertTrue(mockYnabClient.sync.called)
Пример #2
0
    def test_typeOK_noaccount(self):
        data = {'transactions': [{'amount': 10}]}

        def _getacount(accountname):
            return None

        body, code = create_transactions_from_ofx(data,
                                                  ynab_client=mockYnabClient)
        self.assertEqual(code, 400)
Пример #3
0
    def test_typeOK_payeefound(self):
        data = {
            'transactions': [{
                'amount': 10,
                'id': 'id',
                'created': '2017-05-05',
                'currency': '',
                'local_currency': '',
                'merchant': {
                    'name': 'merchant_name'
                }
            }]
        }

        def _getacount(accountname):
            return None

        transaction_list = []

        body, code = create_transactions_from_ofx(data,
                                                  ynab_client=mockYnabClient)
        self.assertEqual(code, 201)
        transactions_append = mockYnabClient.client.budget.be_transactions.append
        self.assertTrue(transactions_append.called)
        self.assertEqual(transactions_append.call_count, 1)

        tup, dic = transactions_append.call_args
        self.assertEqual({}, dic)
        self.assertEqual(len(tup), 1)
        appended_transaction = tup[-1]

        self.assertTrue(mockYnabClient.client.push.called)
        tup, dic = mockYnabClient.client.push.call_args
        self.assertEqual({}, dic)
        self.assertEqual(len(tup), 1)
        self.assertEqual(1, tup[-1])
Пример #4
0
 def test_nodata(self):
     yield self.check_nodata, create_transactions_from_ofx()
Пример #5
0
 def check_nodata(self, func_name):
     data = {}
     body, code = create_transactions_from_ofx(data,
                                               ynab_client=mockYnabClient)
     self.assertEqual(code, 400)
Пример #6
0
 def test_wrongtype(self):
     yield self.check_wrongtype, create_transactions_from_ofx()
Пример #7
0
 def check_wrongtype(self, func_name):
     data = dict(type='Meh')
     body, code = create_transactions_from_ofx(data,
                                               ynab_client=mockYnabClient)
     self.assertEqual(code, 400)