Пример #1
0
    def test_update_form(self):

        banktransactiontag = BankTransactionTagFactory(owner=self.superowner)

        url = reverse('banktransactiontags:update', kwargs={
            'pk': banktransactiontag.pk
        })
        form = self.app.get(url, user='******').form

        self.assertNotIn('owner', form.fields)

        form['name'] = 'rename'
        response = form.submit().maybe_follow()

        banktransactiontag.refresh_from_db()
        self.assertEqual(banktransactiontag.name, 'rename')
        self.assertEqual(banktransactiontag.owner.pk, self.superowner.pk)

        storage = messages.get_messages(response.context[0].request)
        self.assertIn(
            'Bank transaction tag %(name)s was updated successfully.' % {
                'name': banktransactiontag.name
            },
            [message.message for message in storage],
        )
Пример #2
0
    def test_delete_bankaccount(self):

        bankaccount = BankAccountFactory()
        tag = BankTransactionTagFactory()
        BankTransactionFactory(bankaccount=bankaccount, tag=tag)

        pk = bankaccount.pk
        bankaccount.delete()

        self.assertEqual(BankTransaction.objects.filter(bankaccount__pk=pk).count(), 0)
        # Should not be deleted.
        tag.refresh_from_db()
Пример #3
0
    def test_delete_bankaccount(self):

        bankaccount = BankAccountFactory()
        tag = BankTransactionTagFactory()
        BankTransactionFactory(bankaccount=bankaccount, tag=tag)

        pk = bankaccount.pk
        bankaccount.delete()

        self.assertEqual(
            BankTransaction.objects.filter(bankaccount__pk=pk).count(),
            0,
        )
        # Should not be deleted.
        tag.refresh_from_db()
Пример #4
0
    def test_delete_form(self):

        banktransactiontag = BankTransactionTagFactory(owner=self.superowner)

        url = reverse('banktransactiontags:delete', kwargs={
            'pk': banktransactiontag.pk
        })

        response = self.app.get(url, user='******')
        response = response.click(description=_('Cancel'))
        self.assertEqual(response.request.path, reverse('banktransactiontags:list'))
        banktransactiontag.refresh_from_db()

        response = (self.app.get(url, user='******')
                    .form.submit()
                    .maybe_follow())
        self.assertEqual(response.request.path, reverse('banktransactiontags:list'))
        with self.assertRaises(BankTransactionTag.DoesNotExist):
            banktransactiontag.refresh_from_db()
Пример #5
0
    def test_delete_form(self):

        banktransactiontag = BankTransactionTagFactory(owner=self.superowner)

        url = reverse('banktransactiontags:delete',
                      kwargs={'pk': banktransactiontag.pk})

        response = self.app.get(url, user='******')
        response = response.click(description=_('Cancel'))
        self.assertEqual(response.request.path,
                         reverse('banktransactiontags:list'))
        banktransactiontag.refresh_from_db()

        response = (self.app.get(
            url, user='******').form.submit().maybe_follow())
        self.assertEqual(response.request.path,
                         reverse('banktransactiontags:list'))
        with self.assertRaises(BankTransactionTag.DoesNotExist):
            banktransactiontag.refresh_from_db()
Пример #6
0
    def test_update_form(self):

        banktransactiontag = BankTransactionTagFactory(owner=self.superowner)

        url = reverse('banktransactiontags:update',
                      kwargs={'pk': banktransactiontag.pk})
        form = self.app.get(url, user='******').form

        self.assertNotIn('owner', form.fields)

        form['name'] = 'rename'
        response = form.submit().maybe_follow()

        banktransactiontag.refresh_from_db()
        self.assertEqual(banktransactiontag.name, 'rename')
        self.assertEqual(banktransactiontag.owner.pk, self.superowner.pk)

        storage = messages.get_messages(response.context[0].request)
        self.assertIn(
            'Bank transaction tag %(name)s was updated successfully.' %
            {'name': banktransactiontag.name},
            [message.message for message in storage],
        )