Exemplo n.º 1
0
    def test_missing_contacts(self):
        person = models.Person(
            legal_name = "Test Person",
            slug       = 'test-person'
        )
        person.save()
        
        self.assertItemsEqual(
            [ i.category.slug for i in Task.objects_for(person) ],
            ['find-missing-phone', 'find-missing-email', 'find-missing-address'],
        )

        # add a phone number and check that the tasks get updated
        phone = models.ContactKind(
            slug='phone', name='Phone',
        )
        phone.save()

        contact = models.Contact(
            content_type = ContentType.objects.get_for_model(person),
            object_id    = person.id,
            kind         = phone,
            value        = '07891 234 567',
        )
        contact.save()

        self.assertItemsEqual(
            [ i.category.slug for i in Task.objects_for(person) ],
            ['find-missing-email', 'find-missing-address'],
        )
Exemplo n.º 2
0
    def test_missing_contacts(self):

        self.assertItemsEqual(
            [i.category.slug for i in Task.objects_for(self.person)],
            [
                'find-missing-phone', 'find-missing-email',
                'find-missing-address'
            ],
        )

        # add a phone number and check that the tasks get updated

        contact = models.Contact(
            content_type=ContentType.objects.get_for_model(self.person),
            object_id=self.person.id,
            kind=self.phone,
            value='07891 234 567',
            preferred=False,
        )
        contact.save()

        self.assertItemsEqual(
            [i.category.slug for i in Task.objects_for(self.person)],
            ['find-missing-email', 'find-missing-address'],
        )
    def test_missing_contacts(self):

        self.assertItemsEqual(
            [i.category.slug for i in Task.objects_for(self.person)],
            ["find-missing-phone", "find-missing-email", "find-missing-address"],
        )

        # add a phone number and check that the tasks get updated

        contact = models.Contact(
            content_type=ContentType.objects.get_for_model(self.person),
            object_id=self.person.id,
            kind=self.phone,
            value="07891 234 567",
        )
        contact.save()

        self.assertItemsEqual(
            [i.category.slug for i in Task.objects_for(self.person)], ["find-missing-email", "find-missing-address"]
        )
Exemplo n.º 4
0
 def generate_tasks(self):
     """generate tasks for ourselves, and for the foreign object"""
     Task.call_generate_tasks_on_if_possible(self.content_object)
     return []
Exemplo n.º 5
0
#!/usr/bin/env python

"""
Go through all models that are task related and check that all tasks have been
generated.
"""


from pombola.core import models
from pombola.tasks.models import Task

task_related_models = [ models.Person, models.Contact ]

for m in task_related_models:
    for obj in m.objects.all():
        Task.call_generate_tasks_on( obj )