<s> """<STR_LIT>""" <EOL> import classes <EOL> import utils <EOL> import copy <EOL> import settings <EOL> import response_codes <EOL> import py <EOL> class TestMultipleMatching ( ) : <EOL> def setup_class ( self ) : <EOL> self . driver = classes . Driver ( settings . DRIVER_USERNAME , settings . DRIVER_PASSWORD , settings . DYCAPO_URL ) <EOL> self . rider1 = classes . Rider ( "<STR_LIT>" , settings . RIDER_PASSWORD , settings . DYCAPO_URL ) <EOL> self . rider2 = classes . Rider ( "<STR_LIT>" , settings . RIDER_PASSWORD , settings . DYCAPO_URL ) <EOL> self . rider3 = classes . Rider ( "<STR_LIT>" , settings . RIDER_PASSWORD , settings . DYCAPO_URL ) <EOL> self . rider4 = classes . Rider ( "<STR_LIT>" , settings . RIDER_PASSWORD , settings . DYCAPO_URL ) <EOL> self . riders = [ self . rider1 , self . rider2 , self . rider3 , self . rider4 ] <EOL> self . rider5 = classes . Rider ( settings . RIDER_USERNAME , settings . RIDER_PASSWORD , settings . DYCAPO_URL ) <EOL> self . rider6 = classes . Rider ( "<STR_LIT>" , settings . RIDER_PASSWORD , settings . DYCAPO_URL ) <EOL> self . driver_position = '<STR_LIT>' <EOL> self . driver_destination = '<STR_LIT>' <EOL> self . rider_position = '<STR_LIT>' <EOL> self . rider_destination = '<STR_LIT>' <EOL> def teardown_class ( self ) : <EOL> if settings . FINISH_TRIP_AFTER_TESTS : <EOL> self . driver . finish_trip ( self . driver . trip ) <EOL> def setup_method ( self , method ) : <EOL> self . driver . location = classes . Location ( georss_point = self . driver_position ) <EOL> self . driver . destination = classes . Location ( georss_point = self . driver_destination , point = '<STR_LIT>' ) <EOL> self . rider5 . location = classes . Location ( georss_point = self . rider_position ) <EOL> self . rider5 . destination = classes . Location ( georss_point = self . rider_destination , point = '<STR_LIT>' ) <EOL> self . rider6 . location = classes . Location ( georss_point = self . rider_position ) <EOL> self . rider6 . destination = classes . Location ( georss_point = self . rider_destination , point = '<STR_LIT>' ) <EOL> for rider in self . riders : <EOL> rider . location = classes . Location ( georss_point = self . rider_position ) <EOL> rider . destination = classes . Location ( georss_point = self . rider_destination , point = '<STR_LIT>' ) <EOL> def test_position ( self ) : <EOL> response = self . driver . update_position ( ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . CREATED or response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> response = self . driver . get_position ( ) <EOL> assert response [ '<STR_LIT:value>' ] [ '<STR_LIT>' ] == self . driver . location . georss_point <EOL> self . driver . location = response [ '<STR_LIT:value>' ] <EOL> response = self . rider5 . update_position ( ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . CREATED or response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> response = self . rider5 . get_position ( ) <EOL> assert response [ '<STR_LIT:value>' ] [ '<STR_LIT>' ] == self . rider5 . location . georss_point <EOL> self . rider5 . location = response [ '<STR_LIT:value>' ] <EOL> response = self . rider6 . update_position ( location = self . rider6 . location ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . CREATED or response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> response = self . rider6 . get_position ( ) <EOL> assert response [ '<STR_LIT:value>' ] [ '<STR_LIT>' ] == self . rider6 . location . georss_point <EOL> self . rider6 . location = response [ '<STR_LIT:value>' ] <EOL> for rider in self . riders : <EOL> response = rider . update_position ( ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . CREATED or response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> response = rider . get_position ( ) <EOL> assert response [ '<STR_LIT:value>' ] [ '<STR_LIT>' ] == rider . location . georss_point <EOL> rider . location = response [ '<STR_LIT:value>' ] <EOL> def test_insert_trip_exp ( self ) : <EOL> response = self . driver . insert_trip_exp ( ) <EOL> assert response [ '<STR_LIT:value>' ] [ '<STR_LIT:id>' ] > <NUM_LIT:0> <EOL> assert [ location for location in response [ '<STR_LIT:value>' ] [ '<STR_LIT>' ] if location [ '<STR_LIT>' ] == '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] == self . driver_destination <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> self . driver . trip = response [ '<STR_LIT:value>' ] <EOL> def test_search_trip_before_start ( self ) : <EOL> for rider in self . riders : <EOL> response = rider . search_ride ( rider . location , rider . destination ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> with py . test . raises ( KeyError ) : <EOL> assert response [ '<STR_LIT>' ] == True <EOL> def test_start_trip ( self ) : <EOL> response = self . driver . start_trip ( ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> def test_search_trip_after_start ( self ) : <EOL> for rider in self . riders : <EOL> response = rider . search_ride ( rider . location , rider . destination ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> rider . trip = response [ '<STR_LIT:value>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> def test_search_trip_driver_closest_to_destination ( self ) : <EOL> driver_position = '<STR_LIT>' <EOL> self . driver . location = classes . Location ( georss_point = driver_position , point = '<STR_LIT>' ) <EOL> self . driver . update_position ( ) <EOL> response = self . rider1 . search_ride ( self . rider1 . location , self . rider1 . destination ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> with py . test . raises ( KeyError ) : <EOL> assert response [ '<STR_LIT>' ] == True <EOL> self . driver . location = classes . Location ( georss_point = self . driver_position ) <EOL> self . driver . update_position ( ) <EOL> def test_check_ride_requests_before_request ( self ) : <EOL> response = self . driver . check_ride_requests ( ) <EOL> assert len ( response [ '<STR_LIT:value>' ] ) == <NUM_LIT:0> <EOL> def test_get_position_before_request ( self ) : <EOL> for rider in self . riders : <EOL> response = self . driver . get_position ( person = rider ) <EOL> print rider . username <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . FORBIDDEN <EOL> def test_request_ride ( self ) : <EOL> for rider in self . riders : <EOL> response = rider . request_ride ( trip = rider . trip ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . CREATED or response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> def test_check_ride_requests_after_request ( self ) : <EOL> for rider in self . riders : <EOL> response = self . driver . check_ride_requests ( ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> self . driver . ride_request = response [ '<STR_LIT:value>' ] <EOL> def test_accept_ride_request ( self ) : <EOL> for rider in self . driver . ride_request : <EOL> response = self . driver . accept_ride_request ( rider ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> def test_get_position_after_request ( self ) : <EOL> for rider in self . riders : <EOL> response = self . driver . get_position ( person = rider ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> def test_start_ride ( self ) : <EOL> for rider in self . riders : <EOL> if not hasattr ( rider , "<STR_LIT>" ) : <EOL> break <EOL> response = rider . start_ride ( rider . trip ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> def test_search_trip_no_vacany ( self ) : <EOL> response = self . rider5 . search_ride ( self . rider5 . location , self . rider5 . destination ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> with py . test . raises ( KeyError ) : <EOL> assert response [ '<STR_LIT>' ] == True <EOL> def test_search_trip_vacany ( self ) : <EOL> response = self . rider4 . finish_ride ( self . rider4 . trip ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> response = self . rider5 . search_ride ( self . rider5 . location , self . rider5 . destination ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> self . rider5 . trip = response [ '<STR_LIT:value>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> def test_request_ride_rider5 ( self ) : <EOL> response = self . rider5 . request_ride ( trip = self . rider5 . trip ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . CREATED or response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> def test_check_ride_request_rider5 ( self ) : <EOL> response = self . driver . check_ride_requests ( ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> participation = utils . get_requested_participation ( response [ '<STR_LIT:value>' ] ) <EOL> assert participation [ '<STR_LIT>' ] [ '<STR_LIT:username>' ] == self . rider5 . username <EOL> self . driver . ride_request = response [ '<STR_LIT:value>' ] <EOL> def test_cancel_requested_ride ( self ) : <EOL> response = self . rider5 . cancel_requested_ride ( trip = self . rider5 . trip ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . DELETED <EOL> def test_check_cancelled_ride_request_rider5 ( self ) : <EOL> response = self . driver . check_ride_requests ( ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> participation = utils . get_requested_participation ( response [ '<STR_LIT:value>' ] ) <EOL> assert not participation <EOL> def test_get_position_cancelled_ride_request ( self ) : <EOL> response = self . driver . get_position ( self . rider5 ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . FORBIDDEN <EOL> def test_search_trip_rider6 ( self ) : <EOL> response = self . rider6 . search_ride ( self . rider6 . location , self . rider6 . destination ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> self . rider6 . trip = response [ '<STR_LIT:value>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> def test_request_ride_rider6 ( self ) : <EOL> response = self . rider6 . request_ride ( trip = self . rider6 . trip ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . CREATED or response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> def test_check_ride_request_rider5 ( self ) : <EOL> response = self . driver . check_ride_requests ( ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> participation = utils . get_requested_participation ( response [ '<STR_LIT:value>' ] ) <EOL> assert participation [ '<STR_LIT>' ] [ '<STR_LIT:username>' ] == self . rider6 . username <EOL> self . driver . ride_request = response [ '<STR_LIT:value>' ] <EOL> def test_finish_ride ( self ) : <EOL> for rider in self . riders : <EOL> if not hasattr ( rider , "<STR_LIT>" ) : <EOL> break <EOL> response = rider . finish_ride ( rider . trip ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . ALL_OK <EOL> def test_get_position_after_ride_finished ( self ) : <EOL> for rider in self . riders : <EOL> response = self . driver . get_position ( person = rider ) <EOL> assert response [ '<STR_LIT:code>' ] == response_codes . FORBIDDEN </s>
