コード例 #1
0
    def test_create_lookuppointofinterest_model_data_2_result(self):
        # 4 valid clinics, shows two
        Location_Sender.vumi_client = lambda x: LoggingSender('go_http.test')
        Metric_Sender.vumi_client = lambda x: LoggingSender('go_http.test')

        post_data = {
            "search": {
                "hct": "true"
            },
            "response": {
                "type": "SMS",
                "to_addr": "+27123",
                "template": "Your nearest x is: {{ results }}"
            },
            "location": self.create_location(18.71208, -33.85105)
        }
        response = self.client.post('/clinicfinder/requestlookup/',
                                    json.dumps(post_data),
                                    content_type='application/json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        d = LookupPointOfInterest.objects.last()
        self.assertEqual(
            d.response["results"], "Harmonie Clinic (0219806185/6205) "
            "AND Hazendal Satellite Clinic (216969920)")
コード例 #2
0
    def test_create_lookuppointofinterest_model_data_no_result(self):
        # no valid clinic
        Location_Sender.vumi_client = lambda x: LoggingSender('go_http.test')
        Metric_Sender.vumi_client = lambda x: LoggingSender('go_http.test')

        post_data = {
            "search": {
                "mmc": "true",
                "hiv": "false"
            },
            "response": {
                "type": "SMS",
                "to_addr": "+27123",
                "template": "Your nearest x is: {{ results }}"
            },
            "location": self.create_location(29.0000000, -33.0000000)
        }
        response = self.client.post('/clinicfinder/requestlookup/',
                                    json.dumps(post_data),
                                    content_type='application/json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        d = LookupPointOfInterest.objects.last()
        self.assertEqual(d.search["mmc"], "true")
        self.assertEqual(d.search["hiv"], "false")
        point = Point(29.0000000, -33.0000000)
        self.assertEqual(d.location.point, point)
        self.assertEqual(d.response["results"], "")
コード例 #3
0
    def test_create_lbsrequest_model_data_no_result(self):
        Location_Sender.vumi_client = lambda x: LoggingSender('go_http.test')
        Metric_Sender.vumi_client = lambda x: LoggingSender('go_http.test')
        LBS_Lookup.add_allowed_msisdn = self.stub_add_allowed_msisdn
        LBS_Lookup.get_location = self.stub_get_location_no_result

        post_data = {
            "search": {
                "msisdn": "27123"
            },
            "pointofinterest":
            self.create_poi_lookup('requestlookup', {"mmc": "true"})
        }
        response = self.client.post('/clinicfinder/lbsrequest/',
                                    json.dumps(post_data),
                                    content_type='application/json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        lbs = LBSRequest.objects.last()
        # Search for MMC saved
        self.assertEqual(lbs.pointofinterest.search["mmc"], "true")
        self.assertEqual(lbs.search["msisdn"], "27123")
        # LBS Call denied
        self.assertEqual(lbs.response["lookup_code"], "201")
        # LBS Call Result did not create new point
        lpoi = LookupPointOfInterest.objects.last()
        self.assertEqual(lpoi.location, None)
コード例 #4
0
    def test_create_lbsrequest_model_data(self):
        Location_Sender.vumi_client = lambda x: LoggingSender('go_http.test')
        Metric_Sender.vumi_client = lambda x: LoggingSender('go_http.test')
        LBS_Lookup.add_allowed_msisdn = self.stub_add_allowed_msisdn
        LBS_Lookup.get_location = self.stub_get_location_get_result

        post_data = {
            "search": {
                "msisdn": "27123"
            },
            "pointofinterest":
            self.create_poi_lookup('requestlookup', {"mmc": "true"})
        }
        response = self.client.post('/clinicfinder/lbsrequest/',
                                    json.dumps(post_data),
                                    content_type='application/json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        lbs = LBSRequest.objects.last()
        # Search for MMC saved
        self.assertEqual(lbs.pointofinterest.search["mmc"], "true")
        self.assertEqual(lbs.search["msisdn"], "27123")
        # LBS Call worked
        self.assertEqual(lbs.response["lookup_code"], "101")
        # LBS Call Result created new point
        lpoi = LookupPointOfInterest.objects.last()
        point = Point(17.9145812988280005, -32.7461242675779979)
        self.assertEqual(lpoi.location.point, point)
        self.assertEqual(lpoi.response["results"],
                         "Seapoint Clinic (Seapoint)")
コード例 #5
0
 def test_fire_metric(self):
     Metric_Sender.vumi_client = lambda x: LoggingSender('go_http.test')
     result = metric_sender.delay(metric="sms.noresults",
                                  value=1,
                                  agg="sum")
     self.assertTrue(result.successful())
     self.assertEquals(result.get()["reason"], "Metrics published")
コード例 #6
0
    def test_create_forward_result(self):
        # 4 valid clinics, shows two
        Location_Sender.vumi_client = lambda x: LoggingSender('go_http.test')

        post_data = {
            "search": {
                "hct": "true"
            },
            "response": {
                "type": "SMS",
                "to_addr": "+27123",
                "template": "Your nearest x is: {{ results }}"
            },
            "location": self.create_location(18.458404541015, -33.92578125)
        }
        response = self.client.post('/clinicfinder/requestlookup/',
                                    json.dumps(post_data),
                                    content_type='application/json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        d = LookupPointOfInterest.objects.last()
        self.assertEqual(d.response["results"], "Clinic One (Tel One) "
                         "AND Clinic Two (Tel Two)")