示例#1
0
 def test_db_access(self):
     # todo: this currently fails because the override of the swappable model
     # happens after the DB is initialized.
     # there may be some complex workarounds to this (https://stackoverflow.com/q/502916/8207),
     # but for now just take the same approach that the framework does
     # (see: https://github.com/wq/django-swappable-models/blob/master/tests/test_swapper.py#L61)
     self.assertEqual(0, get_contact_model().objects.count())
示例#2
0
 def test_save_load(self):
     test_utils.setup_basic_contacts(self)
     self.assertEqual(3, get_contact_model().objects.count())
     self.p1.a_new_field = 'test the new stuff'
     self.p1.save()
     self.assertEqual('test the new stuff', get_contact_model().objects.get(pk=self.p1.pk).a_new_field)
示例#3
0
 def test_swappable_model_accessor(self):
     self.assertEqual(ExampleContact, get_contact_model())
示例#4
0
import datetime

from django.contrib.auth import models as auth
from contacts import get_contact_model

import contacts.models as cont
import backend.models as auto

Contact = get_contact_model()


def setup_auth_user(cls):
    # Creat dummy admin user
    cls.user = auth.User.objects.create_user("test",
                                             "*****@*****.**",
                                             "test",
                                             first_name="Test Nurse")
    cont.Practitioner.objects.create(user=cls.user, facility="bondo")


def setup_auto_messages(cls):
    # Create dummy auto messages
    cls.signup_control_msg = auto.AutomatedMessage.objects.create(
        send_base="signup",
        english="Control English Signup Message",
        todo=False,
        group='control',
        condition='normal',
    )

    cls.signup_msg = auto.AutomatedMessage.objects.create(