Ejemplo n.º 1
0
    def setUp(self):
        self.router = MockRouter()

        self.backend = self.router.add_backend(u'MockBackend', 'rapidsms.tests.harness')
        self.assertIsNotNone(self.backend)
        self.assertEquals(self.router.backends[u'MockBackend'], self.backend)

        backend_in_db = Backend.objects.create(name=u'MockBackend')
        backend_in_db.save()

        self.contact = Contact.objects.create(first_name='John',
                                              last_name='Doe')
        self.connection = Connection.objects.create(contact=self.contact,
                                                    backend=backend_in_db,
                                                    identity='1112223333')
        self.patient = self.create_patient(data={'contact': self.contact })

        self.app = DecisionApp(router=self.router)
        self.router.add_app(self.app)
        self.tree =  get_tree()
        self.backend.start()
        self.app.start()
        self.survey = PatientSurvey.objects.create(patient=self.patient,
                                                   query_type=QUERY_TYPE_SMS)
        super(TreeTest,self).setUp()
Ejemplo n.º 2
0
    def setUp(self):
        self.router = MockRouter()

        self.backend = self.router.add_backend(u'MockBackend',
                                               'rapidsms.tests.harness')
        self.assertIsNotNone(self.backend)
        self.assertEquals(self.router.backends[u'MockBackend'], self.backend)

        backend_in_db = Backend.objects.create(name=u'MockBackend')
        backend_in_db.save()

        self.contact = Contact.objects.create(first_name='John',
                                              last_name='Doe')
        self.connection = Connection.objects.create(contact=self.contact,
                                                    backend=backend_in_db,
                                                    identity='1112223333')
        self.patient = self.create_patient(data={'contact': self.contact})

        self.app = DecisionApp(router=self.router)
        self.router.add_app(self.app)
        self.tree = get_tree()
        self.backend.start()
        self.app.start()
        self.survey = PatientSurvey.objects.create(patient=self.patient,
                                                   query_type=QUERY_TYPE_SMS)
        super(TreeTest, self).setUp()
Ejemplo n.º 3
0
    def can_change_decisiontree_text(self):
        """Test that once the tree is created in the database, we can
        change the messages in the database and it'll get used.
        """

        # Force creation of tree
        tree = get_tree()
        # Get first question
        q1 = tree.root_state.question
        self.assertEquals(q1.text, "How many pills did you miss in the last four days?")
        
        # now change the text in the database
        NEW_TEXT = "test me!"
        q1.text = NEW_TEXT
        q1.save()
        
        q1 = get_tree().root_state.question
        self.assertEquals(q1.text, NEW_TEXT)
Ejemplo n.º 4
0
    def can_change_decisiontree_text(self):
        """Test that once the tree is created in the database, we can
        change the messages in the database and it'll get used.
        """

        # Force creation of tree
        tree = get_tree()
        # Get first question
        q1 = tree.root_state.question
        self.assertEquals(
            q1.text, "How many pills did you miss in the last four days?")

        # now change the text in the database
        NEW_TEXT = "test me!"
        q1.text = NEW_TEXT
        q1.save()

        q1 = get_tree().root_state.question
        self.assertEquals(q1.text, NEW_TEXT)