Esempio n. 1
0
def test_car_status_updated_location_position_status():
    coords1 = {
        'carIndex': 0,
        'location': {
            'lat': 52.07640151591944,
            'long': -1.0184079172947025
        },
        'timestamp': 1554566859732
    }
    car_status = Car(coords1)
    car_status.update_status(coords1)

    coords2 = {
        'carIndex': 0,
        'location': {
            'lat': 52.07649426484038,
            'long': -1.0185149430328098
        },
        'timestamp': 1554566859933
    }
    car_status.update_status(coords2)
    car_status.current_position = 1
    actual = car_status.get_current_position_status()

    expected = {
        'carIndex': 0,
        'timestamp': coords2['timestamp'],
        'type': CarStatusTypes.POSITION.name,
        'value': 1
    }
    assert actual == expected
    assert car_status._cur_loc == (coords2['location']['long'],
                                   coords2['location']['lat'])
    assert car_status._cur_timestamp == coords2['timestamp']
Esempio n. 2
0
    def _update_car_status(self, car_coordinates):
        car_index = car_coordinates['carIndex']
        if car_index not in self._cars:
            car = Car(car_coordinates)
            self._cars[car_index] = car

        self._cars[car_index].update_status(car_coordinates)
Esempio n. 3
0
def test_car_status_updated_location_speed_status():
    coords1 = {
        'carIndex': 0,
        'location': {
            'lat': 52.07640151591944,
            'long': -1.0184079172947025
        },
        'timestamp': 1554566859732
    }
    car_status = Car(coords1)
    car_status.update_status(coords1)

    coords2 = {
        'carIndex': 0,
        'location': {
            'lat': 52.07649426484038,
            'long': -1.0185149430328098
        },
        'timestamp': 1554566859933
    }
    car_status.update_status(coords2)
    actual = car_status.get_current_speed_status()

    expected = {
        'carIndex': 0,
        'timestamp': coords2['timestamp'],
        'type': CarStatusTypes.SPEED.name,
        'value': 175
    }
    assert actual == expected
Esempio n. 4
0
    def setUp(self):
        """
        Setup function to initialize different model lists
        """

        part1 = Part("PARTLIST_5E6B2", "PART_1F2BA", 1386, 50)
        part2 = Part("PARTLIST_5E6B2", "PART_95365", 1546, 42)
        part3 = Part("PARTLIST_06D40", "PART_C5965", 2725, 32)
        part4 = Part("PARTLIST_06D40", "PART_FAEF0", 3834, 25)
        part5 = Part("PARTLIST_33599", "PART_AC9B8", 3769, 26)
        car1 = Car("CARID_1402", "MODEL_B1BFE", 124, 160, "PARTLIST_5E6B2")
        car2 = Car("CARID_7347", "MODEL_39E91", 104, 205, "PARTLIST_06D40")
        car3 = Car("CARID_3861", "MODEL_3B4C7", 120, 201, "PARTLIST_33599")
        team1 = Team("0", "Force India", ["CARID_1402", "CARID_7347"], 9000)
        team2 = Team("2", "Mercedes", ["CARID_3861"], 8770)
        PartList.parts = [part1, part2, part3, part4, part5]
        CarList.cars = [car1, car2, car3]
        TeamList.teams = [team1, team2]
Esempio n. 5
0
def test_car_status_initial_position_None():
    coords1 = {
        'carIndex': 0,
        'location': {
            'lat': 52.07640151591944,
            'long': -1.0184079172947025
        },
        'timestamp': 1554566859732
    }
    car_status = Car(coords1)
    car_status.update_status(coords1)

    actual = car_status.get_current_position_status()

    expected = {
        'carIndex': 0,
        'timestamp': coords1['timestamp'],
        'type': CarStatusTypes.POSITION.name,
        'value': None
    }
    assert actual == expected
Esempio n. 6
0
def test_car_status_initial_status():
    coordinates = {
        'carIndex': 0,
        'location': {
            'lat': 52.06371964824748,
            'long': -1.0169126377630506
        },
        'timestamp': 1554565525039
    }

    car_status = Car(coordinates)
    car_status.update_status(coordinates)
    actual = car_status.get_current_position_status()

    expected = {
        'timestamp': coordinates['timestamp'],
        'carIndex': coordinates['carIndex'],
        'type': CarStatusTypes.POSITION.name,
        'value': None,
    }
    assert actual == expected
    def test_car_model(self):
        """
        Unittests to test car model
        """

        car = Car("CARID_1402", "MODEL_B1BFE", 124, 160, "PARTLIST_5E6B2")
        self.assertEqual("CARID_1402", car.get_car_id())
        self.assertEqual("MODEL_B1BFE", car.get_car_name())
        self.assertEqual(124, car.get_base_speed())
        self.assertEqual(160, car.get_top_speed())
        self.assertEqual("PARTLIST_5E6B2", car.get_part_list_id())