# coding: utf-8

from django.test import TestCase
from mock import Mock
from eventex.subscriptions.admin import SubscriptionAdmin
from eventex.subscriptions.models import Subscription
from django.contrib import admin

class MarkAsPaidTest(TestCase):

    def setUp(self):
        'Instancia o Model Admin'
        self.model_admin = SubscriptionAdmin(Subscription, admin.site)

        'Cria um registro no banco de dados'
        Subscription.objects.create(
            name="Fabiano Weimar dos Santos",
            cpf="12345678901",
            email="xiru@xiru.org",
            phone="51-12341234"
        )


    def test_has_action(self):
        'Verifica se a action está instalada'
        self.assertIn('mark_as_paid', self.model_admin.actions)

    def test_mark_all(self):
        'Marca tudo como pago'
        fake_request = Mock()
        qs = Subscription.objects.all()
        self.model_admin.mark_as_paid(fake_request, qs)
        self.assertEqual(1, Subscription.objects.filter(paid=True).count())
