Exemplo n.º 1
0
 def test_should_have_at_least_one_direction(self):
     self.assertGreaterEqual(len(
         Station(Faker().word, {
             'd': TimeTableStub(tuple())
         }).get_directions()),
                             1,
                             msg='Should have at least one direction')
Exemplo n.º 2
0
 def test_should_have_time_table_for_direction(self):
     self.assertIsInstance(
         Station(
             Faker().word,
             {'abc123': TimeTableStub(tuple())}
         ).time_tables['abc123'],
         TimeTable
     )
Exemplo n.º 3
0
    def test_should_have_name(self, mock_time_table):
        mock_time_table.get_departure_times.return_value = (4234, '6576', 45645)

        station_name = Faker().word
        self.assertEqual(
            station_name,
            Station(station_name, {Faker().word: mock_time_table}).get_name(),
            msg=f'Should be {station_name}'
        )
Exemplo n.º 4
0
import unittest

import mock
from faker import Faker

from clock import Clock
from station.station import Station
from time_table.time_table import TimeTable


class Route:
    def __init__(self, route_name: str, stations: tuple):
        self.stations = {station.get_name(): station for station in stations}
        self.route_name = route_name


if __name__ == '__main__':
    directions = {
        'Gdańsk': TimeTable((345, 6546, 75688, 6537)),
        'Reda': TimeTable((45465, 8678, 9758))
    }

    station = Station('Rumia', directions)
    route = Route('Reda - Gdańsk', (station, ))

    print('Następny pociąg ze stacji {} do stacji {} odjedzie o godzinie {}'.
          format('Rumia', 'Gdańsk',
                 route.stations['Rumia'].get_next_departure_time('Gdańsk')))
Exemplo n.º 5
0
 def test_should_return_next_departure_time_depending_on_direction(self):
     station = Station(Faker().word, {'abc123': TimeTableStub(tuple())})
     self.assertGreater(
         Clock.get_hour_in_seconds(
             station.get_next_departure_time('abc123')), Clock.get_time())
Exemplo n.º 6
0
 def setUp(self) -> None:
     self.station = Station(Faker().word, {'d': TimeTableStub(tuple())})