コード例 #1
0
ファイル: group_test.py プロジェクト: AdeneganJosiah/Sendinel
 def manage_groups(self, infoservice_type, table_head, member_button, 
                   remove_button, remove_patient_button, group_name):
     info = InfoService(name = "testgroup", type = infoservice_type)
     info.save()
     
     patient = Patient(phone_number = "012345")
     patient.save()
     
     subscription = Subscription(infoservice = info, 
                                 patient = patient,
                                 way_of_communication = get_woc("voice"))
     subscription.save()
     
     response = self.client.get(reverse("infoservices_index",
                                 kwargs = {'infoservice_type': infoservice_type}))
     self.assertContains(response, member_button)
     self.assertContains(response, remove_button)
     self.assertContains(response, table_head)
     
     response = self.client.get(reverse("infoservices_members", 
                                                kwargs={"id": info.id,
                                                }))
                                                        
     self.assertContains(response, patient.phone_number)
     self.assertContains(response, remove_patient_button)
     self.assertContains(response, group_name)
コード例 #2
0
ファイル: utils.py プロジェクト: AdeneganJosiah/Sendinel
def subscription_save(request, id):
    '''
        save patient and subscription
        @return subscription
    '''
    patient = request.session['patient']
    patient.save()
    way_of_communication = request.session['way_of_communication']
    infoservice = InfoService.objects.filter(pk = id)[0]
    subscription = Subscription(patient = patient,
                                way_of_communication = way_of_communication,
                                infoservice = infoservice)
    subscription.save()
    logger.info("Saved subscription %s of type %s.", 
                (unicode(subscription), 
                 unicode(subscription.infoservice.type)))
    return subscription
コード例 #3
0
ファイル: group_test.py プロジェクト: AdeneganJosiah/Sendinel
 def setUp(self):
     self.info = InfoService(name = "testinfoservice", type="information")
     self.info.save()
     self.patient = Patient(name="eu",phone_number = "01234")
     self.patient.save()
     self.subscription = Subscription(infoservice = self.info, 
                                      way_of_communication = get_woc("sms"), 
                                      patient = self.patient)
     self.subscription.save()
コード例 #4
0
class SubscriptionTest(TestCase):
    
    fixtures = ["backend_test"]
    
    def setUp(self):
        self.woc = get_woc("sms")
    
        self.infoservice = InfoService(name = "Gruppe", 
                                       type = "information")
        self.infoservice.save()
        self.patient = Patient()
        self.patient.save()
        self.subscription = Subscription(patient = self.patient, 
                                         infoservice = self.infoservice,
                                         way_of_communication = self.woc)
        self.subscription.save()
        
    def test_infoservice_member_relation_add(self):
        self.assertTrue(self.patient in self.infoservice.members.all())

    def test_infoservice_member_relation_delete(self):
        self.subscription.delete()
        self.assertTrue(self.patient not in self.infoservice.members.all())
        
    def test_subscription_creation(self):
        subscription = Subscription()        
        
        self.assertRaises(IntegrityError, subscription.save)
        
        infoservice = InfoService(name = "information", type="information")
        infoservice.save()
        
        subscription.patient = self.patient
        subscription.infoservice = infoservice
        subscription.way_of_communication = self.woc
        
        subscription.save()
        
        self.assertEquals(self.infoservice.members.all().count(), 1)
        self.assertEquals(self.infoservice.members.all()[0], self.patient)
        self.assertTrue(subscription in Subscription.objects.all())
コード例 #5
0
 def setUp(self):
     self.woc = get_woc("sms")
 
     self.infoservice = InfoService(name = "Gruppe", 
                                    type = "information")
     self.infoservice.save()
     self.patient = Patient()
     self.patient.save()
     self.subscription = Subscription(patient = self.patient, 
                                      infoservice = self.infoservice,
                                      way_of_communication = self.woc)
     self.subscription.save()
コード例 #6
0
 def test_send_message(self):
     a_medicine = InfoService(name='Malarone', type='medicine')
     a_medicine.save()
     subscription = Subscription(patient = Patient.objects.all()[0],
                             way_of_communication = get_woc("sms"),
                             infoservice = a_medicine)
     subscription.save()
     subscription = Subscription(patient = Patient.objects.all()[1],
                             way_of_communication = get_woc("sms"),
                             infoservice = a_medicine)
     subscription.save()
     info_service_count = InfoService.objects.all().count()
     members_count = a_medicine.members.count()
     scheduled_events_count = ScheduledEvent.objects.all().count()
     a_text = 'Hello, the medicine Malarone is now available at your ' + \
              'clinic. Please come and pick it up.'
     response = self.client.post(reverse('medicines_send_message'),
                                  { 'medicine': a_medicine.pk, 
                                    'text': a_text })
                                    
     self.assertEquals(InfoService.objects.all().count() +  1, 
                       info_service_count)
     self.assertEquals(ScheduledEvent.objects.all().count(),
                       scheduled_events_count + members_count)
     self.assertTemplateUsed(response, 'web/status_message.html')
     self.assertTemplateNotUsed(response, 'medicine/message_create.html')
コード例 #7
0
 def test_subscription_creation(self):
     subscription = Subscription()        
     
     self.assertRaises(IntegrityError, subscription.save)
     
     infoservice = InfoService(name = "information", type="information")
     infoservice.save()
     
     subscription.patient = self.patient
     subscription.infoservice = infoservice
     subscription.way_of_communication = self.woc
     
     subscription.save()
     
     self.assertEquals(self.infoservice.members.all().count(), 1)
     self.assertEquals(self.infoservice.members.all()[0], self.patient)
     self.assertTrue(subscription in Subscription.objects.all())
コード例 #8
0
ファイル: group_test.py プロジェクト: AdeneganJosiah/Sendinel
class WebInfoServiceTest(TestCase):
    
    fixtures = ['backend_test']
    

    def setUp(self):
        self.info = InfoService(name = "testinfoservice", type="information")
        self.info.save()
        self.patient = Patient(name="eu",phone_number = "01234")
        self.patient.save()
        self.subscription = Subscription(infoservice = self.info, 
                                         way_of_communication = get_woc("sms"), 
                                         patient = self.patient)
        self.subscription.save()
     
    def create_register_form(self):
        response = self.client.get(reverse('groups_register', 
                                    kwargs={'group_id': self.info.id}))
        self.failUnlessEqual(response.status_code, 200)
        self.assertContains(response, 'name="phone_number"')
        self.assertContains(response, 'name="way_of_communication"')
        return response
        
    def test_infoservices_on_main_page(self):
        response = self.client.get(reverse('web_index'))

        infoservices = InfoService.objects.all()
        for infoservice in infoservices:
            if infoservice.type == "information":
                self.assertContains(response, infoservice.name)
                self.assertContains(response, 
                                reverse('groups_register',
                                         kwargs={'group_id': infoservice.id}))
            else:
                self.assertNotContains(response, infoservice.name)

    @disable_authentication
    def test_register(self):
        redirection_path = reverse('groups_register_save', \
                                    kwargs = {'group_id': self.info.id})

        self.create_register_form()
        response = self.client.post(reverse('groups_register', 
                                    kwargs={'group_id': self.info.id}),
                                    {'way_of_communication': 1,
                                     'phone_number':'01234 / 56789012'})

        self.assertTrue(self.client.session.has_key('way_of_communication'))
        self.assertTrue(self.client.session.has_key('authenticate_phonenumber'))
        
        self.assertEquals(response.status_code, 302)
        self.assertRedirects(response, redirection_path)
        return response
        

    @disable_authentication
    def test_register_submit_validations(self):
       
        response = self.client.post(reverse('groups_register', 
                                    kwargs={'group_id': self.info.id}),
                                    {'way_of_communication': 1,
                                     'phone_number':'01234 / 56789012'})

        self.assertEquals(response.status_code, 302)

        response = self.client.post(reverse('groups_register', 
                                    kwargs={'group_id': self.info.id}),
                                    {'way_of_communication': 1,
                                     'phone_number':'0123afffg789012'})
        self.assertContains(response, 'Please enter numbers only')

        response = self.client.post(reverse('groups_register', 
                                    kwargs={'group_id': self.info.id}),
                                    {'way_of_communication': 1,
                                     'phone_number':'234 / 56789012'})
        self.assertContains(response, 'Please enter a cell phone number.')
        
        


        
    def test_register_save(self):
        subscription_count = Subscription.objects.all().count()

        self.client.post(reverse('groups_register',
                         kwargs={'group_id': self.info.id}),
                         {"way_of_communication": 1,
                          "phone_number": "0123456"})
                          
        response = self.client.get(reverse('groups_register_save',
                                   kwargs={'group_id': self.info.id}))
                                                               
        self.assertEquals(Subscription.objects.all().count(),
                          subscription_count + 1)
        new_subscription = last(Subscription)
        self.assertEquals(new_subscription.patient.phone_number, "0123456")
        self.assertEquals(new_subscription.infoservice, self.info)
        self.assertEquals(new_subscription.way_of_communication, get_woc("sms"))
        

    
    def test_remove_subscription(self):
        subscription_count = Subscription.objects.all().count()
        
        self.subscription.delete()
                            
        self.assertEquals(Subscription.objects.all().count(), 
                          subscription_count - 1)
        self.assertTrue(Subscription.objects.filter(pk = self.info.id).count() == 0)