<s> import unittest <EOL> from graphserver . core import * <EOL> class TestHeadwayAlight ( unittest . TestCase ) : <EOL> def test_basic ( self ) : <EOL> sc = ServiceCalendar ( ) <EOL> sc . add_period ( <NUM_LIT:0> , <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> tz = Timezone ( ) <EOL> tz . add_period ( TimezonePeriod ( <NUM_LIT:0> , <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , <NUM_LIT:0> ) ) <EOL> ha = HeadwayAlight ( "<STR_LIT>" , sc , tz , <NUM_LIT:0> , "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:1000> , <NUM_LIT:100> ) <EOL> assert ha . calendar . soul == sc . soul <EOL> assert ha . timezone . soul == tz . soul <EOL> assert ha . agency == <NUM_LIT:0> <EOL> assert ha . int_service_id == <NUM_LIT:0> <EOL> assert ha . trip_id == "<STR_LIT>" <EOL> assert ha . start_time == <NUM_LIT:0> <EOL> assert ha . end_time == <NUM_LIT:1000> <EOL> assert ha . headway_secs == <NUM_LIT:100> <EOL> ha . destroy ( ) <EOL> def test_walk_back ( self ) : <EOL> sc = ServiceCalendar ( ) <EOL> sc . add_period ( <NUM_LIT:0> , <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , [ '<STR_LIT>' ] ) <EOL> tz = Timezone ( ) <EOL> tz . add_period ( TimezonePeriod ( <NUM_LIT:0> , <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , <NUM_LIT:0> ) ) <EOL> ha = HeadwayAlight ( "<STR_LIT>" , sc , tz , <NUM_LIT:0> , "<STR_LIT>" , <NUM_LIT:200> , <NUM_LIT:1000> , <NUM_LIT:50> ) <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 . time == <NUM_LIT:1000> <EOL> assert s1 . weight == <NUM_LIT> <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT:1000> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 . time == <NUM_LIT:1000> <EOL> assert s1 . weight == <NUM_LIT:1> <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 . time == <NUM_LIT> <EOL> assert s1 . weight == <NUM_LIT:1> <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT:200> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 . time == <NUM_LIT:200> <EOL> assert s1 . weight == <NUM_LIT:1> <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 == None <EOL> def test_walk ( self ) : <EOL> sc = ServiceCalendar ( ) <EOL> sc . add_period ( <NUM_LIT:0> , <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , [ '<STR_LIT>' ] ) <EOL> tz = Timezone ( ) <EOL> tz . add_period ( TimezonePeriod ( <NUM_LIT:0> , <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , <NUM_LIT:0> ) ) <EOL> ha = HeadwayAlight ( "<STR_LIT>" , sc , tz , <NUM_LIT:0> , "<STR_LIT>" , <NUM_LIT:200> , <NUM_LIT:1000> , <NUM_LIT:50> ) <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> s1 = ha . walk ( s0 , WalkOptions ( ) ) <EOL> assert s1 . trip_id == None <EOL> def test_headwayalight_over_midnight ( self ) : <EOL> sc = ServiceCalendar ( ) <EOL> sc . add_period ( <NUM_LIT:0> , <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , [ '<STR_LIT>' ] ) <EOL> sc . add_period ( <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , <NUM_LIT:2> * <NUM_LIT> * <NUM_LIT> , [ '<STR_LIT>' ] ) <EOL> tz = Timezone ( ) <EOL> tz . add_period ( TimezonePeriod ( <NUM_LIT:0> , <NUM_LIT:2> * <NUM_LIT> * <NUM_LIT> , <NUM_LIT:0> ) ) <EOL> ha = HeadwayAlight ( "<STR_LIT>" , sc , tz , <NUM_LIT:0> , "<STR_LIT>" , <NUM_LIT> * <NUM_LIT> , <NUM_LIT> * <NUM_LIT> , <NUM_LIT:100> ) <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT> * <NUM_LIT> + <NUM_LIT:100> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 . weight == <NUM_LIT> <EOL> assert s1 . service_period ( <NUM_LIT:0> ) . service_ids == [ <NUM_LIT:1> ] <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT> * <NUM_LIT> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 . weight == <NUM_LIT:1> <EOL> assert s1 . service_period ( <NUM_LIT:0> ) . service_ids == [ <NUM_LIT:1> ] <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT> * <NUM_LIT> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 . time == <NUM_LIT> * <NUM_LIT> <EOL> assert s1 . weight == <NUM_LIT:1> <EOL> assert s1 . service_period ( <NUM_LIT:0> ) . service_ids == [ <NUM_LIT:1> ] <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT> * <NUM_LIT> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 . weight == <NUM_LIT:1> <EOL> assert s1 . service_period ( <NUM_LIT:0> ) . service_ids == [ <NUM_LIT:1> ] <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT> * <NUM_LIT> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 . time == <NUM_LIT> * <NUM_LIT> <EOL> assert s1 . weight == <NUM_LIT:1> <EOL> assert s1 . service_period ( <NUM_LIT:0> ) . service_ids == [ <NUM_LIT:0> ] <EOL> s0 = State ( <NUM_LIT:1> , <NUM_LIT> * <NUM_LIT> - <NUM_LIT:1> ) <EOL> s1 = ha . walk_back ( s0 , WalkOptions ( ) ) <EOL> assert s1 == None <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> tl = unittest . TestLoader ( ) <EOL> suite = tl . loadTestsFromTestCase ( TestHeadwayAlight ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) </s>
