Esempio n. 1
0
    def test_two_distint_ships_per_year(self):
        ships = [
            model.Ship(None, day=1, year=2070),
            model.Ship(None, day=1, year=2080)
        ]

        self.assertEqual(2070, trader.get_earliest_ship(ships).year)
Esempio n. 2
0
    def test_more_distint_ships_per_day(self):
        ships = [
            model.Ship(None, day=21, year=2070),
            model.Ship(None, day=15, year=2070),
            model.Ship(None, day=7, year=2070),
            model.Ship(None, day=20, year=2070)
        ]

        self.assertEqual(7, trader.get_earliest_ship(ships).day)
Esempio n. 3
0
    def test_more_distint_ships_per_day_and_year(self):
        ships = [
            model.Ship(None, day=21, year=2070),
            model.Ship(None, day=15, year=2085),
            model.Ship(None, day=7, year=2090),
            model.Ship(None, day=20, year=2071)
        ]

        selected_ship = trader.get_earliest_ship(ships)
        self.assertEqual(21, selected_ship.day)
        self.assertEqual(2070, selected_ship.year)
Esempio n. 4
0
    def test_two_distint_ships_same_day(self):
        """
        As this case contains a random return, it may fail rare cases. The test
        should test the sttistical distribution.
        """
        ships = [
            model.Ship(None, name="one", day=20, year=2070),
            model.Ship(None, name="two", day=20, year=2070)
        ]

        selected_ship_count = 0
        for i in range(100):
            new_ship = trader.get_earliest_ship(ships)
            if new_ship.name == "one":
                selected_ship_count += 1

        self.assertTrue(40 < selected_ship_count < 60)

        self.assertEqual(20, trader.get_earliest_ship(ships).day)
Esempio n. 5
0
def ship():
    return m.Ship(None, day=1, year=2070)
Esempio n. 6
0
def test_start_location_none():
    ship = m.Ship(None, m.StarDate())
    assert ship.star is None
Esempio n. 7
0
def test_can_set_location():
    ship = m.Ship(None, m.StarDate())
    ship.location = "here"
    assert "here" == ship.star
    assert "here" == ship.location