コード例 #1
0
ファイル: test_admin.py プロジェクト: olivx/eventex
class SubscriptionModelAdmin(TestCase):
    def setUp(self):
        Subscription.objects.create(
            name="Thiago Olivieira", cpf=12345678901, email="*****@*****.**", phone="11-970513508"
        )
        self.model_admin = SubscriptionsModelAdmin(Subscription, admin.site)
        self.queryset = Subscription.objects.all()

    def test_has_action(self):
        """ Action mark_as_paid should be installed """
        self.assertIn("mark_as_paid", self.model_admin.actions)

    def test_mark_as_paid(self):
        """it Should be all mark subscription as paid"""
        self.call_action()

        self.model_admin.mark_as_paid(None, self.queryset)
        self.assertEquals(1, Subscription.objects.filter(paid=True).count())

    def test_message(self):
        """it Should send message to user"""

        mock = self.call_action()
        self.model_admin.mark_as_paid(None, self.queryset)
        mock.assert_called_once_with(None, "1 inscrição foi marcada como paga.")

    def call_action(self):
        mock = Mock()
        old_message_user = self.model_admin.message_user
        SubscriptionsModelAdmin.message_user = mock

        Subscription.message_user = old_message_user
        return mock
コード例 #2
0
class SubscritptionModelAdminTest(TestCase):
    def setUp(self):
        Subscription.objects.create(name='Junior', cpf='12345678901',
                                    email='*****@*****.**', phone='21996015875')
        self.model_admin = SubscriptionsModelAdmin(Subscription, admin.site)

    def test_has_action(self):
        """ Action mark_as_paid should be installed. """
        self.assertIn('mark_as_paid', self.model_admin.actions)

    def test_mark_all(self):
        """It should mark all selected subscriptions as paid."""
        self.call_action()
        self.assertEqual(1, Subscription.objects.filter(paid=True).count())

    def test_message(self):
        """It should send a message to the user"""
        mock = self.call_action()
        mock.assert_called_once_with(None, '1 inscrição foi marcada como paga.')

    def call_action(self):
        queryset = Subscription.objects.all()

        mock = Mock()
        old_message_user = SubscriptionsModelAdmin.message_user
        SubscriptionsModelAdmin.message_user = mock

        self.model_admin.mark_as_paid(None, queryset)

        SubscriptionsModelAdmin.message_user = old_message_user

        return mock
コード例 #3
0
class SubscriptionModelAdmin(TestCase):
    def setUp(self):
        Subscription.objects.create(name="Thiago Olivieira", cpf=12345678901,
                                    email="*****@*****.**",
                                    phone="11-970513508")
        self.model_admin = SubscriptionsModelAdmin(Subscription, admin.site)
        self.queryset = Subscription.objects.all()

    def test_has_action(self):
        """ Action mark_as_paid should be installed """
        self.assertIn('mark_as_paid', self.model_admin.actions)

    def test_mark_as_paid(self):
        """it Should be all mark subscription as paid"""
        self.call_action()

        self.model_admin.mark_as_paid(None, self.queryset)
        self.assertEquals(1, Subscription.objects.filter(paid=True).count())

    def test_message(self):
        """it Should send message to user"""

        mock = self.call_action()
        self.model_admin.mark_as_paid(None, self.queryset)
        mock.assert_called_once_with(None, '1 inscrição foi marcada como paga.')

    def call_action(self):
        mock = Mock()
        old_message_user = self.model_admin.message_user
        SubscriptionsModelAdmin.message_user = mock

        Subscription.message_user = old_message_user
        return mock
コード例 #4
0
ファイル: test_admin.py プロジェクト: luizolimpio/wttd
    def call_action(self):
        model_admin = SubscriptionsModelAdmin(Subscription,admin.site)
        queryset = Subscription.objects.all()

        mock = Mock()
        old_menssage_user =SubscriptionsModelAdmin.message_user
        SubscriptionsModelAdmin.message_user = mock

        model_admin.mark_as_paid(None,queryset)

        SubscriptionsModelAdmin.message_user = old_menssage_user
        return mock
コード例 #5
0
ファイル: test_admin.py プロジェクト: olivx/eventex
 def setUp(self):
     Subscription.objects.create(
         name="Thiago Olivieira", cpf=12345678901, email="*****@*****.**", phone="11-970513508"
     )
     self.model_admin = SubscriptionsModelAdmin(Subscription, admin.site)
     self.queryset = Subscription.objects.all()
コード例 #6
0
 def setUp(self):
     Subscription.objects.create(name='Junior', cpf='12345678901',
                                 email='*****@*****.**', phone='21996015875')
     self.model_admin = SubscriptionsModelAdmin(Subscription, admin.site)
コード例 #7
0
 def setUp(self):
     Subscription.objects.create(name="Thiago Olivieira", cpf=12345678901,
                                 email="*****@*****.**",
                                 phone="11-970513508")
     self.model_admin = SubscriptionsModelAdmin(Subscription, admin.site)
     self.queryset = Subscription.objects.all()