Пример #1
0
 def from_json(dto, trip_id):
     return StepTransportBus(
         name=dto.get('name'),
         trip_id=trip_id,
         start_datetime=dto.get('start_datetime'),
         end_datetime=dto.get('end_datetime'),
         start_address=Place.from_json(dto.get('start_address')),
         end_address=Place.from_json(dto.get('end_address')),
         phone_number=dto.get('phone_number'),
         notes=dto.get('notes'),
         reservation_number=dto.get('reservation_number'),
         transport_number=dto.get('transport_number'))
Пример #2
0
 def test_get_business_id_with_no_result_should_raise_exception(self):
     responses.add(responses.GET,
                   '{}/matches'.format(url),
                   status=200,
                   json={"businesses": []})
     with self.assertRaises(BusinessNotFoundException):
         get_business_id(Place(id=1))
Пример #3
0
    def test_get_rating_should_return_rating(self):
        business_id = 'EDjIDq3VGlDQAxtdOslPCA'
        responses.add(responses.GET,
                      '{}/matches'.format(url),
                      status=200,
                      json={
                          "businesses": [{
                              "id":
                              business_id,
                              "alias":
                              "cracker-barrel-old-country-store-hattiesburg",
                              "name":
                              "Cracker Barrel Old Country Store",
                          }]
                      })
        responses.add(responses.GET,
                      '{}/{}/reviews'.format(url, business_id),
                      status=200,
                      json={
                          "reviews": [{
                              "id": "mLmKOhUW87byM7lsMDDz_w",
                              "rating": 3,
                          }, {
                              "id": "Al1G6S7IZcIVFdSAA-fKgw",
                              "rating": 1,
                          }, {
                              "id": "3uxMqhNcZdmbt4p08gSZyQ",
                              "rating": 2,
                          }],
                          "total":
                          46
                      })

        self.assertEqual(2, get_rating(Place()))
Пример #4
0
 def test_get_business_id_with_api_error_status_should_raise_exception(
         self):
     responses.add(responses.GET,
                   '{}/matches'.format(url),
                   status=400,
                   json={})
     with self.assertRaises(BusinessNotFoundException):
         get_business_id(Place(id=1))
Пример #5
0
 def from_json(dto, trip_id):
     return Step(name=dto.get('name'),
                 trip_id=trip_id,
                 start_datetime=dto.get('start_datetime'),
                 end_datetime=dto.get('end_datetime'),
                 start_address=Place.from_json(dto.get('start_address')),
                 phone_number=dto.get('phone_number'),
                 notes=dto.get('notes'))
Пример #6
0
 def test_get_business_id_should_return_business_id(self):
     responses.add(responses.GET,
                   '{}/matches'.format(url),
                   status=200,
                   json={
                       "businesses": [{
                           "id":
                           "EDjIDq3VGlDQAxtdOslPCA",
                           "alias":
                           "cracker-barrel-old-country-store-hattiesburg",
                           "name":
                           "Cracker Barrel Old Country Store",
                       }]
                   })
     self.assertEqual('EDjIDq3VGlDQAxtdOslPCA', get_business_id(Place()))