Esempio n. 1
0
def test_bridge_total_weight():
    tollbridge = Bridge()
    mb = Motorbike("abc", 182)
    lorry = Lorry("abc", 5000)
    tollbridge.add_vehicle(mb)
    tollbridge.add_vehicle(lorry)
    assert tollbridge.calculate_total_weight() == 5182
Esempio n. 2
0
def default_motorbike():
    yield Motorbike("5050", 150)
Esempio n. 3
0
def test_create_motorbike_weight():
    mb = Motorbike("abc", 182)
    assert mb.weight == 182
Esempio n. 4
0
def test_create_motorbike_reg():
    mb = Motorbike("abc", 182)
    assert mb.reg == "abc"
Esempio n. 5
0
def test_create_motorbike_fee():
    mb = Motorbike("abc", 182)
    fee = mb.calculate_fee()
    assert fee == 3.00
Esempio n. 6
0
        # If on or above 30k kg, return False (don't add), else return True (fine to add)
        return total_weight

    def add_vehicle(self, vehicle_to_add):
        if len(self.vehicles) <= 20:
            if self.calc_total_weight() + vehicle_to_add.weight <= 30000:
                self.vehicles.append(vehicle_to_add)
                return True
        return False

    def remove_car(self, reg_to_find):
        if len(self.vehicles) == 0:
            return False

        for vehicle in self.vehicles:
            if vehicle.reg_num == reg_to_find:
                self.vehicles.remove(vehicle)
                return True
        return False

    def __repr__(self):
        return "Bridge=(vehicles={})".format(self.vehicles)


if __name__ == '__main__':
    bridges = Bridge()
    motorbike1 = Motorbike("5050", 1250)

    bridges.add_vehicle(motorbike1)
    print(bridges)
Esempio n. 7
0
def test_add_to_bridge_weight():
    tollbridge = Bridge(2, 5182)
    mb = Motorbike("abc", 182)
    tollbridge.add_vehicle(mb)
    lorry = Lorry("abc", 5000)
    assert tollbridge.add_vehicle(lorry) is True
Esempio n. 8
0
def test_add_to_full_bridge():
    tollbridge = Bridge(1, 10000)
    mb = Motorbike("abc", 182)
    tollbridge.add_vehicle(mb)
    lorry = Lorry("abc", 5000)
    assert tollbridge.add_vehicle(lorry) is False
Esempio n. 9
0
def test_add_to_bridge():
    tollbridge = Bridge()
    mb = Motorbike("abc", 182)
    assert tollbridge.add_vehicle(mb) is True