Exemplo n.º 1
0
    def test_trip_complete_status(self):
        """
			Checks status of the trip when it gets completed.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))
        trip_started_response = json.loads(
            customer_action.board_cab(
                response_for_cab_request["data"]["trip_id"]))
        response_for_finished_trip = json.loads(
            customer_action.make_payment_and_offboard(
                response_for_cab_request["data"]["trip_id"]))

        self.assertTrue(response_for_finished_trip["is_success"])
        self.assertEqual(response_for_finished_trip["response_code"], 200)
        self.assertEqual(response_for_finished_trip["data"]["trip_status"],
                         "Trip Completed")
Exemplo n.º 2
0
    def test_rebooking_same_cab(self):
        """
			When a cab is booked, it should not get rebooked untill it becomes available.
			This test case contains only one registered cab with 2 nearby customers requesting for the same.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))

        another_customer_pickup_location = Location(11.35, 37.12)
        another_customer_drop_location = Location(42.62, 68.0)

        another_customer_action = CustomerAction.get_action_object(
            customer_id=101, trip_dispatcher=self.__trip_dispatcher)
        another_cab_request_response = json.loads(
            another_customer_action.request_cab(
                another_customer_pickup_location,
                another_customer_drop_location))

        self.assertFalse(another_cab_request_response["is_success"])
        self.assertEqual(another_cab_request_response["error_message"],
                         "No cab can be allocated")
Exemplo n.º 3
0
    def test_trip_order_amount(self):
        """
			Checks order amount generation after trip gets completed.
			Order amount is that amount which customer ows after completing the trip.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.CabColor.COLOR_PINK
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location, color))
        trip_started_response = json.loads(
            customer_action.board_cab(
                response_for_cab_request["data"]["trip_id"]))
        response_for_finished_trip = json.loads(
            customer_action.make_payment_and_offboard(
                response_for_cab_request["data"]["trip_id"]))

        self.assertTrue(response_for_finished_trip["is_success"])
        self.assertEqual(response_for_finished_trip["response_code"], 200)
        self.assertEqual(
            response_for_finished_trip["data"]["order_summary"]
            ["order_amount"], 238.35)
Exemplo n.º 4
0
    def test_trip_cancel_after_trip_started(self):
        """
			Checks if customer can cancel the trip after s/he starts it /  boards the cab.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))
        trip_started_response = json.loads(
            customer_action.board_cab(
                response_for_cab_request["data"]["trip_id"]))
        trip_cancelled_response = json.loads(
            customer_action.cancel_trip(
                response_for_cab_request["data"]["trip_id"]))

        self.assertFalse(trip_cancelled_response["is_success"])
        self.assertEqual(trip_cancelled_response["response_code"], 250)
        self.assertEqual(
            trip_cancelled_response["error_message"],
            "Trip not requested, not dispatched or already started")
Exemplo n.º 5
0
 def from_raw(
     driver_id: int,
     route: List[int],
     time: List[int],
     locations: Optional[List[str]] = None,
 ) -> "Schedule":
     driver = Driver(id=driver_id)
     driver_route = [
         Route(
             id=i,
             start=Location(name=locations[route[i]] if locations else str(
                 route[i])),  # pass name if given
             end=Location(
                 name=locations[route[i +
                                      1]] if locations else str(route[i +
                                                                      1])),
             duration=time[i + 1] - time[i],
             arrival_time=(
                 datetime.now() +
                 timedelta(seconds=time[i + 1]) - timedelta(
                     seconds=time[0])  # remove starting load from time calc
             ).time(),
         ) for i in range(len(route) - 1)
     ]
     return Schedule(driver=driver, route=driver_route)
 def test_reverse_ascending():
     customer_one = CustomerRecord(
         Customer(user_id=11, name="Alice Cahill"),
         Location(latitude=51.92893, longitude=-10.27699))
     customer_two = CustomerRecord(
         Customer(user_id=4, name="Ian Kehoe"),
         Location(latitude=53.2451022, longitude=-6.238335))
     customer_three = CustomerRecord(
         Customer(user_id=9, name="Alice Cahill"),
         Location(latitude=51.92893, longitude=-10.27699))
     data = [customer_one, customer_two, customer_three]
     extracted_data = Extractor.extract_customer(data)
     Sorting.sort_customers(extracted_data, True)
     assert len(extracted_data) == 3
     assert extracted_data[0].user_id <= extracted_data[1].user_id
     assert extracted_data[1].user_id <= extracted_data[2].user_id
Exemplo n.º 7
0
 async def _store(self, ctx):
     """View store information and inventory."""
     player = Player(ctx.message.author.id)
     location = Location(player.current_location)
     store_ids = self.stores.list_id()
     for store_id in store_ids:
         store = Store(store_id)
         prices = store.settings['prices']
         if store.location.location_id == player.current_location:
             embed = discord.Embed(
                 title=location.name,
                 color=discord.Color.green(),
                 description='Welcome to **' + store.name + '**, ' + ctx.message.author.display_name + '!')
             items = self.items.list()
             embed.add_field(name='Items for Sale', value='The following are available for sale.\n', inline=False)
             for item in items:
                 if item['id'] in store.available_items:
                     embed.add_field(
                         name=item['emoji'] + ' ' + str(item['id']) + '. ' + item['name'],
                         value='Price: ' + str(prices[str(item['id'])])
                     )
             embed.set_footer(text='Requested by '+ctx.message.author.display_name + '. Prices updated: '
                                   + str(prices['date']),
                              icon_url=ctx.message.author.avatar_url)
             if hasattr(store, 'thumbnail'):
                 embed.set_thumbnail(url=store.thumbnail)
             await ctx.send(embed=embed)
    def test_filter_by_distance_happy_scenario(get_filter_by_distance_obj):
        customer_one = CustomerRecord(
            Customer(user_id=1, name="Alice Cahill"),
            Location(latitude=51.92893, longitude=-10.27699))
        customer_two = CustomerRecord(
            Customer(user_id=4, name="Ian Kehoe"),
            Location(latitude=53.2451022, longitude=-6.238335))

        result = get_filter_by_distance_obj.filter(
            [customer_one, customer_two], DUBLIN_OFFICE_LOCATION,
            INVITATION_RANGE_THRESHOLD_IN_KILOMETERS)

        assert len(result) == 1
        assert result[0].customer.user_id == 4
        assert result[0].customer.name == "Ian Kehoe"
        assert result[0].location.latitude == 53.2451022
        assert result[0].location.longitude == -6.238335
 def test_extractor_happy_scenario():
     data = [
         CustomerRecord(Customer(user_id=1, name="Alice Cahill"),
                        Location(latitude=51.92893, longitude=-10.27699))
     ]
     result = Extractor.extract_customer(data)
     assert len(result) == 1
     assert isinstance(result[0], Customer)
     assert result[0].user_id == 1
     assert result[0].name == "Alice Cahill"
Exemplo n.º 10
0
 async def _subway(self, ctx, location_id: int = 0):
     """Use map to view station map, or an id to move to another station."""
     await ctx.trigger_typing()
     if not location_id:
         return await ctx.send('Try either map or a valid location id.')
     player = Player(ctx.message.author.id)
     if player.current_location == location_id:
         return await ctx.send('You are already there.')
     distance = abs(location_id - player.current_location)
     current_location = Location(player.current_location)
     await ctx.send(':train: ' + ctx.message.author.display_name +
                    ' is now leaving: **' + current_location.name +
                    '** :train:')
     player.move_to(location_id)
     location = Location(location_id)
     time.sleep(distance)
     return await ctx.send(':train: ' + ctx.message.author.display_name +
                           ' is now arriving at: **' + location.name +
                           '** :train:')
Exemplo n.º 11
0
    def test_trip_dispatched_status(self):
        """
			Checks trip allocation / dispatch status.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))
        self.assertTrue(response_for_cab_request["is_success"])
        self.assertEqual(response_for_cab_request["response_code"], 200)
        self.assertEqual(response_for_cab_request["data"]["trip_status"],
                         "Trip Allocated")
Exemplo n.º 12
0
    def test_trip_start_with_invalid_trip_id(self):
        """
			Tests if with invalid details, trip can be started.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        trip_started_response = json.loads(
            customer_action.board_cab('123-hfje33-3344'))

        self.assertFalse(trip_started_response["is_success"])
        self.assertEqual(trip_started_response["response_code"], 250)
        self.assertEqual(trip_started_response["error_message"],
                         "Trip information not found !!!")
Exemplo n.º 13
0
    def test_dispatch_without_cab(self):
        """
			Without cabs being registered, no cab can be allocated on customer's request.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)
        """
			No cab has been registered here. So no cab available. Customer request will be rejected.
		"""

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))

        self.assertFalse(response_for_cab_request["is_success"])
        self.assertEqual(response_for_cab_request["response_code"], 250)
        self.assertEqual(response_for_cab_request["error_message"],
                         "No cab can be allocated")
Exemplo n.º 14
0
    def test_dispatch_without_specific_cab_color(self):
        """
			Tests if cabs without any specific color request can be dispatched.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))

        self.assertEqual(response_for_cab_request["response_code"], 200)
        self.assertEqual(response_for_cab_request["error_message"], "")
        self.assertEqual(response_for_cab_request["data"]["cab_info"]["color"],
                         "White(Default)")
Exemplo n.º 15
0
    def test_request_cab(self):
        """
			When cab gets assigned to a customer, it's in booked state till trip gets completed or cancelled.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))

        self.assertEqual(response_for_cab_request["response_code"], 200)
        self.assertEqual(response_for_cab_request["error_message"], "")
        self.assertEqual(
            response_for_cab_request["data"]["cab_info"]["status"], "Booked")
Exemplo n.º 16
0
    def test_cab_location_after_trip_completed(self):
        """
			After trip completion, the cab location should be as same as the customer drop location as the cab is 
			suppossed to wait around outside the customers house.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))
        trip_started_response = json.loads(
            customer_action.board_cab(
                response_for_cab_request["data"]["trip_id"]))
        trip_finished_response = json.loads(
            customer_action.make_payment_and_offboard(
                response_for_cab_request["data"]["trip_id"]))

        cab_id = trip_finished_response["data"]["cab_info"]["cab_id"]
        cab_obj = self.__cab_registry.get_cab_information(int(cab_id))
        final_cab_location = cab_obj.get_location()

        self.assertEqual(final_cab_location.get_x(),
                         customer_drop_location.get_x())
        self.assertEqual(final_cab_location.get_y(),
                         customer_drop_location.get_y())
Exemplo n.º 17
0
    def test_cab_status_after_trip_cancelled(self):
        """
			After trip gets cancelled, cab should become available.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))
        trip_cancelled_response = json.loads(
            customer_action.cancel_trip(
                response_for_cab_request["data"]["trip_id"]))

        self.assertEqual(trip_cancelled_response["data"]["cab_info"]["status"],
                         "Available")
Exemplo n.º 18
0
    def test_dispatch_with_cab_color(self):
        """
			Tests if cabs with a specific color can be dispatched on customer's request.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        """
			PINK color is assigned to the cab.
		"""
        color = cab_colors.CabColor.COLOR_PINK
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location, color))

        self.assertEqual(response_for_cab_request["response_code"], 200)
        self.assertEqual(response_for_cab_request["error_message"], "")
        self.assertEqual(response_for_cab_request["data"]["cab_info"]["color"],
                         "Pink")
Exemplo n.º 19
0
    def test_trip_finished_without_trip_start(self):
        """
			Tests if trip can be finished without starting it.
		"""
        customer_pickup_location = Location(12.45, 34.55)
        customer_drop_location = Location(45.32, 67.676)

        test_cab_location = Location(10.00, 21.23)
        color = cab_colors.get_dafault_color()
        c = ColoredCab(0, test_cab_location, self.__cab_registry, color)

        customer_action = CustomerAction.get_action_object(
            customer_id=100, trip_dispatcher=self.__trip_dispatcher)
        response_for_cab_request = json.loads(
            customer_action.request_cab(customer_pickup_location,
                                        customer_drop_location))
        response_for_finished_trip = json.loads(
            customer_action.make_payment_and_offboard(
                response_for_cab_request["data"]["trip_id"]))

        self.assertFalse(response_for_finished_trip["is_success"])
        self.assertEqual(response_for_finished_trip["response_code"], 250)
        self.assertEqual(response_for_finished_trip["error_message"],
                         "Trip not started")
Exemplo n.º 20
0
def schedule():
    if request.method == 'POST':
        data = request.get_json()['order']
        check_serv = Service.query.filter_by(
            service_name=data['servicetype']).first()
        print(check_serv, 'service here')
        # addr = Location.query.filter_by(location_pickup = data['address']).first()
        # if not addr:
        address = Location(user_id=current_user.id,
                           location_pickup=data['address'])
        db.session.add(address)
        db.session.commit()
        order_items = Order(user_id=current_user.id,
                            service_id=check_serv.id,
                            dateandtime=data['dateandtime'],
                            location_id=address.id)
        db.session.add(order_items)
        db.session.commit()
        return jsonify({'success': 'success'})
Exemplo n.º 21
0
    def __init__(self, store_id):
        super().__init__()
        self.c.execute(
            '''SELECT id, name, location_id, settings FROM wars_stores WHERE id=?''',
            (store_id, ))
        fetch = self.c.fetchone()
        if not fetch:
            raise Exception('No store with that id')
        store_id, name, location_id, settings = fetch
        self.store_id = store_id
        self.name = name
        self.location = Location(location_id)
        self.settings = json.loads(settings)
        if self.settings['available_items']:
            self.available_items = self.settings['available_items']
        else:
            self.available_items = ItemManager().list_id()

        if 'thumbnail' in self.settings.keys():
            self.thumbnail = self.settings['thumbnail']
 def deserialize(self, raw_data):
     """
     Deserializer method for Customer Records.This method deserializes json strings of customer records
     into objects of Customer Records.
     :param raw_data: List of json strings of customer records
     :return: List of Customer record objects
     """
     if not isinstance(raw_data, List):
         raise BaseDeserializerError(
             "Customer Record Deserializer expects raw input to be a list")
     deserialized_data = []
     logging.info("Starting data deserialization")
     for line in raw_data:
         data = json.loads(line)
         location = Location(float(data[LocationFields.latitude.name]),
                             float(data[LocationFields.longitude.name]))
         customer = Customer(data[CustomerFields.user_id.name],
                             data[CustomerFields.name.name])
         customer_record = CustomerRecord(customer, location)
         deserialized_data.append(customer_record)
     logging.info("Deserialization completed")
     return deserialized_data
Exemplo n.º 23
0
 async def _subway_maps(self, ctx):
     """View a map of this system's stations."""
     await ctx.trigger_typing()
     player = Player(ctx.message.author.id)
     current_location = Location(player.current_location)
     locations = self.locations.list()
     stops_str = ''
     for location in locations:
         if location['id'] == player.current_location:
             stops_str = stops_str + ':small_orange_diamond: '
         else:
             stops_str = stops_str + ':small_blue_diamond: '
         stops_str = stops_str + str(
             location['id']) + '. ' + location['name']
         stores = self.stores.at_location(location['id'])
         if len(stores) > 0:
             stores_str = ' ('
             for store in stores:
                 stores_str = stores_str + store.name
                 if store != stores[-1]:
                     stores_str = stores_str + ', '
             stops_str = stops_str + stores_str
             stops_str = stops_str + ')'
         stops_str = stops_str + '\n'
     guild = ctx.message.guild.name
     embed = discord.Embed(title='Subway Stops',
                           color=discord.Color.blurple(),
                           description='Map of ' + guild +
                           '\nYou are currently in ' +
                           current_location.name)
     embed.set_footer(text='Queried by ' + ctx.message.author.display_name,
                      icon_url=ctx.message.author.avatar_url)
     embed.add_field(name='Stops', value=stops_str)
     embed.set_thumbnail(
         url=
         'https://upload.wikimedia.org/wikipedia/commons/thumb/6/64/MBTA.svg/1200px-MBTA.svg.png'
     )
     return await ctx.send(embed=embed)
Exemplo n.º 24
0
 async def _get_profile(self, ctx):
     """See your player profile, balances, current location and inventory."""
     player = Player(ctx.message.author.id)
     inventory_list = player.get_inventory()
     balances = player.get_balance()
     location = Location(player.current_location)
     stores = self.stores.at_location(player.current_location)
     stores_str = ''
     for store in stores:
         if store.location.location_id == player.current_location:
             if store != stores[-1]:
                 stores_str = stores_str + store.name + ', '
             else:
                 stores_str = stores_str + store.name
     embed = discord.Embed(title='Profile',
                           description='Current Location: ' + location.name,
                           colour=discord.Colour.gold())
     if stores_str != '':
         embed.add_field(name='Stores:', value=stores_str, inline=False)
     inventory_str = ''
     if len(inventory_list) > 0:
         for inventory in inventory_list:
             item_object = Item(inventory['id'])
             inventory_str = inventory_str + item_object.emoji + '(' + str(
                 inventory['count']) + ') ' + ' ' + item_object.name + '\n'
     else:
         inventory_str = 'Empty Inventory'
     embed.add_field(name='Bank Balance:',
                     value=':moneybag:' +
                     '{:20,.0f}'.format(balances['bank']))
     embed.add_field(name='Cash Balance:',
                     value=':moneybag:' +
                     '{:20,.0f}'.format(balances['wallet']))
     embed.add_field(name='Inventory', value=inventory_str, inline=False)
     embed.set_author(name=ctx.message.author.display_name,
                      icon_url=ctx.message.author.avatar_url)
     embed.set_thumbnail(url=ctx.message.author.avatar_url)
     return await ctx.send(embed=embed)
Exemplo n.º 25
0
 def test_customer_record_serializer_happy_scenario(get_customer_record_serializer_obj):
     data = CustomerRecord(Customer(user_id=1, name="Alice Cahill"), Location(latitude=51.92893, longitude=-10.27699))
     result = get_customer_record_serializer_obj.serialize([data])
     assert len(result) == 1
     assert result[0] == '{"customer": {"user_id": 1, "name": "Alice Cahill"}, "location": {"latitude": 51.92893, "longitude": -10.27699}}'
Exemplo n.º 26
0
import os
from src.models.location import Location
import logging

logging.getLogger().setLevel(logging.INFO)
logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')

ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
EARTH_RADIUS_IN_KILOMETERS = 6371
DUBLIN_OFFICE_LOCATION = Location(53.339428, -6.257664)
INVITATION_RANGE_THRESHOLD_IN_KILOMETERS = 100
FILE_OUTPUT_PATH = ROOT_DIR + "/output"
CUSTOMER_RECORDS_FILE_PATH = ROOT_DIR + "/resources/customers.txt"

Exemplo n.º 27
0
 def test_distance_with_same_location():
     distance = Computation.compute_distance(
         Location(51.8856167, -10.4240951),
         Location(51.8856167, -10.4240951))
     assert distance == 0.0
Exemplo n.º 28
0
 def test_distance_with_one_location():
     with pytest.raises(ComputationError) as exception_info:
         Computation.compute_distance(Location(51.8856167, -10.4240951),
                                      None)
     assert exception_info.value.message == "Two locations are needed to calculate the distance"
Exemplo n.º 29
0
 def test_distance_with_different_location():
     distance = Computation.compute_distance(
         Location(51.8856167, -10.4240951), Location(53.339428, -6.257664))
     assert distance == 324.37491200828447