예제 #1
0
 def test_find_providers_perfect_and_imperfect(self):
     providers = create_test_providers()
     logging.info("providers: %s" % providers)
     self.assertEqual(len(providers), Provider.query().count())
     # create booking request
     next_monday_at_9 = testutil.create_datetime_from_weekday_and_hour(
         testutil.MONDAY, 15)
     booking_request = Booking(request_category='physiotherapy',
                               request_location='mtl-downtown',
                               request_datetime=next_monday_at_9)
     booking_responses = db_search.provider_search(booking_request)
     logging.info('Booking Respones:')
     for br in booking_responses:
         logging.info('providers %s on %s at %s' %
                      (br.provider.email, br.timeslot.start.date(),
                       br.timeslot.start.time()))
     # 2 responses
     self.assertEqual(2, len(booking_responses))
     # first provider is perfet match
     br1 = booking_responses[0]
     self.assertTrue(br1.is_perfect_match(booking_request))
     # second provider is not perfect match
     br2 = booking_responses[1]
     self.assertFalse(br2.is_perfect_match(booking_request))
     # assert top provider is p2
     self.assertEqual(providers[2][0], booking_responses[0].provider.key)
예제 #2
0
 def test_find_providers_no_matches_wrong_category(self):
     providers = create_test_providers()
     # create booking request - Saturday at 10 PM
     sat_at_10 = testutil.create_datetime_from_weekday_and_hour(5, 22)
     booking_request = Booking(request_category='osteopath',
                               request_location='mtl-downtown',
                               request_datetime=sat_at_10)
     booking_responses = db_search.provider_search(booking_request)
     logging.info('Booking Respones:')
     # assert top provider is p2
     self.assertEqual(0, len(booking_responses))
예제 #3
0
 def test_find_providers_no_matches_wrong_category(self):
     providers = create_test_providers()
     # create booking request - Saturday at 10 PM
     sat_at_10 = testutil.create_datetime_from_weekday_and_hour(5, 22)
     booking_request = Booking(request_category='osteopath', request_location='mtl-downtown', request_datetime=sat_at_10)
     booking_responses = db_search.provider_search(booking_request)
     logging.info('Booking Respones:')
     # assert top provider is p2
     self.assertEqual(0, len(booking_responses))
     
     
     
예제 #4
0
 def test_find_providers_all_imperfect_matches(self):
     providers = create_test_providers()
     # create booking request - Saturday at 10 PM
     sat_at_10 = testutil.create_datetime_from_weekday_and_hour(testutil.MONDAY, 22)
     booking_request = Booking(request_category='physiotherapy', request_location='mtl-downtown', request_datetime=sat_at_10)
     booking_responses = db_search.provider_search(booking_request)
     logging.info('Booking Respones:')
     for br in booking_responses:
         logging.info('providers %s on %s at %s' % (br.provider.email, br.timeslot.start.date(), br.timeslot.start.time()))
     for br in booking_responses:
         self.assertFalse(br.is_perfect_match(booking_request))
     # assert top provider is p2
     self.assertEqual(providers[1][0], booking_responses[0].provider.key)
예제 #5
0
 def test_find_providers_all_imperfect_matches(self):
     providers = create_test_providers()
     # create booking request - Saturday at 10 PM
     sat_at_10 = testutil.create_datetime_from_weekday_and_hour(
         testutil.MONDAY, 22)
     booking_request = Booking(request_category='physiotherapy',
                               request_location='mtl-downtown',
                               request_datetime=sat_at_10)
     booking_responses = db_search.provider_search(booking_request)
     logging.info('Booking Respones:')
     for br in booking_responses:
         logging.info('providers %s on %s at %s' %
                      (br.provider.email, br.timeslot.start.date(),
                       br.timeslot.start.time()))
     for br in booking_responses:
         self.assertFalse(br.is_perfect_match(booking_request))
     # assert top provider is p2
     self.assertEqual(providers[1][0], booking_responses[0].provider.key)
예제 #6
0
    def testFindBestProviderForBooking(self):
        testCategory = u'physiotherapy'
        testLocation = u'montreal-west'

        # create provider
        p = Provider()
        p.terms_agreement = True
        p.status = 'client_enabled'
        p.first_name = 'Best-Test'
        p.last_name = 'Phys-Io'
        p.category = testCategory
        p.location = testLocation
        p.vanity_url = 'physio_guy'
        pkey = p.put()
        # add a provider's schedule (Thursday Morning)
        s = Schedule()
        s.day = 'thursday'
        s.start_time = 8
        s.end_time = 12
        s.provider = p.key
        s.put()
        # create provider with no schedule
        p = Provider()
        p.first_name = 'NoSchedule'
        p.last_name = 'Phys-Io'
        p.category = testCategory
        p.location = testLocation
        pkey2 = p.put()
        # 2 providers in db
        self.assertEqual(2,
                         Provider.query().count(), '2 providers in datastore')
        # create booking
        b = Booking()
        b.request_category = testCategory
        b.request_location = testLocation
        b.request_datetime = datetime.strptime('2012-04-26 10', '%Y-%m-%d %H')
        b.put()
        # test the matching
        brs = db_search.provider_search(b)
        logging.info('best provider:' + str(brs))
        # assert
        self.assertIsNotNone(brs, 'provider should not be None')
        self.assertEqual(pkey, brs[0].provider.key,
                         'provider keys should be equal')
예제 #7
0
파일: db_test.py 프로젝트: deltron/veosan
 def testFindBestProviderForBooking(self):
     testCategory = u'physiotherapy'
     testLocation = u'montreal-west'
     
     # create provider
     p = Provider()
     p.terms_agreement=True
     p.status = 'client_enabled'
     p.first_name = 'Best-Test'
     p.last_name = 'Phys-Io'
     p.category = testCategory
     p.location = testLocation
     p.vanity_url = 'physio_guy'
     pkey = p.put()
     # add a provider's schedule (Thursday Morning)
     s = Schedule()
     s.day = 'thursday'
     s.start_time = 8
     s.end_time = 12
     s.provider = p.key
     s.put()
     # create provider with no schedule
     p = Provider()
     p.first_name = 'NoSchedule'
     p.last_name = 'Phys-Io'
     p.category = testCategory
     p.location = testLocation
     pkey2 = p.put()
     # 2 providers in db
     self.assertEqual(2, Provider.query().count(), '2 providers in datastore')
     # create booking
     b = Booking()
     b.request_category = testCategory
     b.request_location = testLocation
     b.request_datetime = datetime.strptime('2012-04-26 10', '%Y-%m-%d %H')
     b.put();
     # test the matching
     brs = db_search.provider_search(b)
     logging.info('best provider:' + str(brs))
     # assert
     self.assertIsNotNone(brs, 'provider should not be None')
     self.assertEqual(pkey, brs[0].provider.key, 'provider keys should be equal')
     
예제 #8
0
 def test_find_providers_perfect_and_imperfect(self):
     providers = create_test_providers()
     logging.info("providers: %s" % providers)
     self.assertEqual(len(providers), Provider.query().count())
     # create booking request
     next_monday_at_9 = testutil.create_datetime_from_weekday_and_hour(testutil.MONDAY, 15)
     booking_request = Booking(request_category='physiotherapy', request_location='mtl-downtown', request_datetime=next_monday_at_9)
     booking_responses = db_search.provider_search(booking_request)
     logging.info('Booking Respones:')
     for br in booking_responses:
         logging.info('providers %s on %s at %s' % (br.provider.email, br.timeslot.start.date(), br.timeslot.start.time()))
     # 2 responses
     self.assertEqual(2, len(booking_responses))
     # first provider is perfet match
     br1 = booking_responses[0]
     self.assertTrue(br1.is_perfect_match(booking_request))
     # second provider is not perfect match
     br2 = booking_responses[1]
     self.assertFalse(br2.is_perfect_match(booking_request))
     # assert top provider is p2
     self.assertEqual(providers[2][0], booking_responses[0].provider.key)