Exemplo n.º 1
0
    def test_normal(self, mock_spawn_after, mock_SubwayDaemon,
                    mock_get_database, mock_SafeConfigParser,
                    mock_monkey_patch, mock_LOG):
        mock_SafeConfigParser.return_value = self.setup_config(
            config=dict(a=1, b=2, c=3),
            master=dict(host='master'),
            slave_1=dict(host='slave1'),
        )

        subway.subway('conf_file')
        mock_monkey_patch.assert_called_once_with()
        mock_SafeConfigParser.assert_called_once_with()
        mock_SafeConfigParser.return_value.assert_has_calls([
            mock.call.read(['conf_file']),
            mock.call.items('config'),
            mock.call.has_section('master'),
            mock.call.items('master'),
            mock.call.sections(),
            mock.call.items('slave:1'),
        ])
        mock_get_database.assert_has_calls([
            mock.call(dict(host='master')),
            mock.call(dict(host='slave1')),
        ])
        mock_SubwayDaemon.assert_called_once_with(
            dict(a=1, b=2, c=3), dict(host='master'), [dict(host='slave1')])
        mock_spawn_after.assert_called_once_with(2.0, 'reloader')
        mock_SubwayDaemon.return_value.listen.assert_called_once_with()
        self.assertEqual(len(mock_LOG.method_calls), 0)
Exemplo n.º 2
0
def test_ride_slightly_less_simple():
    simple_ride = subway.ride("stationA", "stationC",
                              subway.subway(blue="stationA stationB stationC"))
    eq_(simple_ride, ["stationA", "blue", "stationB", "blue", "stationC"])
Exemplo n.º 3
0
def test_ride_simple():
    simple_ride = subway.ride("stationA", "stationB", subway.subway(blue="stationA stationB"))
    eq_(simple_ride, ["stationA", "blue", "stationB"])
Exemplo n.º 4
0
def test_subway_crossing():
    crossing = subway.subway(blue="stationA stationB", orange="stationC stationA stationD")
    eq_(crossing["stationA"], { "stationB": "blue", "stationC": "orange", "stationD": "orange" })
Exemplo n.º 5
0
def test_subway_single():
    simple = subway.subway(blue="stationA stationB")

    eq_(simple["stationA"], { "stationB": "blue" })
    eq_(simple["stationB"], { "stationA": "blue" })
Exemplo n.º 6
0
import subway
from nose.tools import eq_

boston = subway.subway(
    blue='bowdoin government state aquarium maverick airport suffolk revere wonderland',
    orange='oakgrove sullivan haymarket state downtown chinatown tufts backbay foresthills',
    green='lechmere science north haymarket government park copley kenmore newton riverside',
    red='alewife davis porter harvard central mit charles park downtown south umass mattapan'
)

def test_subway_single():
    simple = subway.subway(blue="stationA stationB")

    eq_(simple["stationA"], { "stationB": "blue" })
    eq_(simple["stationB"], { "stationA": "blue" })

def test_subway_crossing():
    crossing = subway.subway(blue="stationA stationB", orange="stationC stationA stationD")
    eq_(crossing["stationA"], { "stationB": "blue", "stationC": "orange", "stationD": "orange" })

def test_ride_simple():
    simple_ride = subway.ride("stationA", "stationB", subway.subway(blue="stationA stationB"))
    eq_(simple_ride, ["stationA", "blue", "stationB"])

def test_ride_slightly_less_simple():
    simple_ride = subway.ride("stationA", "stationC",
                              subway.subway(blue="stationA stationB stationC"))
    eq_(simple_ride, ["stationA", "blue", "stationB", "blue", "stationC"])

def test_ride_mit_government():
    eq_(subway.ride('mit', 'government', boston), [ 'mit', 'red', 'charles', 'red', 'park', 'green', 'government'])
Exemplo n.º 7
0
import subway  #각 사람들의 일상을 엿볼 수 있도록
#버스, 택시, 집 추가해야함


class car:
    speed = 80


sb = subway.subway()

speed = 50
station = {"a": 50, "b": 150, "c": 500, "d": 1000, "e": 1150}
commercial = [
    "행복을 이어주는 사람들 - 한국도로공사", "비비는 맛에 산다 - 팔도비빔면", "뭘 먹어도 맛있다 - BBQ",
    "물만큼은 삼다수로 산다 - 삼다수"
]

sb.set_all(speed, station, commercial)
sb.run_subway()