<s> from __future__ import print_function , unicode_literals <EOL> import datetime <EOL> import time <EOL> import unittest <EOL> import weblab . core . coordinator . status as WSS <EOL> from weblab . core . reservations import WaitingReservation , ConfirmedReservation , WaitingConfirmationReservation , WaitingInstances , PostReservationReservation , Reservation <EOL> class ReservationTest ( unittest . TestCase ) : <EOL> def assertCorrectReservation ( self , reservation ) : <EOL> self . assertEquals ( str ( reservation ) , str ( eval ( str ( reservation ) ) ) ) <EOL> def test_str_waiting_reservation ( self ) : <EOL> reservation = WaitingReservation ( "<STR_LIT>" , <NUM_LIT:5> ) <EOL> self . assertCorrectReservation ( reservation ) <EOL> def test_str_waiting_instances_reservation ( self ) : <EOL> reservation = WaitingInstances ( "<STR_LIT>" , <NUM_LIT:5> ) <EOL> self . assertCorrectReservation ( reservation ) <EOL> def test_str_confirmed_reservation ( self ) : <EOL> reservation = ConfirmedReservation ( "<STR_LIT>" , datetime . datetime . now ( ) , "<STR_LIT:{}>" , '<STR_LIT>' , "<STR_LIT>" ) <EOL> self . assertCorrectReservation ( reservation ) <EOL> def test_str_waiting_confirmation_reservation ( self ) : <EOL> reservation = WaitingConfirmationReservation ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> self . assertCorrectReservation ( reservation ) <EOL> def test_str_post_reservation_reservation ( self ) : <EOL> reservation = PostReservationReservation ( "<STR_LIT>" , True , "<STR_LIT:{}>" , '<STR_LIT>' ) <EOL> self . assertCorrectReservation ( reservation ) <EOL> def test_translate_reservation_waiting_instances ( self ) : <EOL> status = WSS . WaitingInstancesQueueStatus ( '<STR_LIT:foo>' , <NUM_LIT:5> ) <EOL> reservation = Reservation . translate_reservation ( status ) <EOL> self . assertEquals ( Reservation . WAITING_INSTANCES , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( <NUM_LIT:5> , reservation . position ) <EOL> self . assertEquals ( status , reservation . to_status ( ) ) <EOL> def test_translate_reservation_waiting ( self ) : <EOL> status = WSS . WaitingQueueStatus ( '<STR_LIT:foo>' , <NUM_LIT:5> ) <EOL> reservation = Reservation . translate_reservation ( status ) <EOL> self . assertEquals ( Reservation . WAITING , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( <NUM_LIT:5> , reservation . position ) <EOL> self . assertEquals ( status , reservation . to_status ( ) ) <EOL> def test_translate_reservation_waiting_confirmation ( self ) : <EOL> status = WSS . WaitingConfirmationQueueStatus ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> reservation = Reservation . translate_reservation ( status ) <EOL> self . assertEquals ( Reservation . WAITING_CONFIRMATION , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( '<STR_LIT>' , reservation . url ) <EOL> self . assertEquals ( status , reservation . to_status ( ) ) <EOL> def test_translate_local_reservation_reserved ( self ) : <EOL> status = WSS . LocalReservedStatus ( '<STR_LIT:foo>' , '<STR_LIT>' , '<STR_LIT>' , { } , <NUM_LIT:100> , "<STR_LIT:{}>" , time . time ( ) , time . time ( ) , True , <NUM_LIT> , '<STR_LIT>' ) <EOL> reservation = Reservation . translate_reservation ( status ) <EOL> self . assertEquals ( Reservation . CONFIRMED , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( '<STR_LIT>' , reservation . url ) <EOL> self . assertEquals ( '<STR_LIT:{}>' , reservation . initial_configuration ) <EOL> status = WSS . RemoteReservedStatus ( '<STR_LIT:foo>' , <NUM_LIT> , '<STR_LIT:{}>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEquals ( status , reservation . to_status ( ) ) <EOL> def test_translate_remote_reservation_reserved ( self ) : <EOL> status = WSS . RemoteReservedStatus ( '<STR_LIT:foo>' , <NUM_LIT:100> , "<STR_LIT:{}>" , '<STR_LIT>' , "<STR_LIT:bar>" ) <EOL> reservation = Reservation . translate_reservation ( status ) <EOL> self . assertEquals ( Reservation . CONFIRMED , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( '<STR_LIT>' , reservation . url ) <EOL> self . assertEquals ( '<STR_LIT:{}>' , reservation . initial_configuration ) <EOL> self . assertEquals ( '<STR_LIT:bar>' , reservation . remote_reservation_id . id ) <EOL> self . assertEquals ( status , reservation . to_status ( ) ) <EOL> def test_translate_reservation_post_reservation ( self ) : <EOL> status = WSS . PostReservationStatus ( '<STR_LIT:foo>' , True , "<STR_LIT>" , "<STR_LIT:{}>" ) <EOL> reservation = Reservation . translate_reservation ( status ) <EOL> self . assertEquals ( Reservation . POST_RESERVATION , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( '<STR_LIT>' , reservation . initial_data ) <EOL> self . assertEquals ( '<STR_LIT:{}>' , reservation . end_data ) <EOL> self . assertTrue ( reservation . finished ) <EOL> self . assertEquals ( status , reservation . to_status ( ) ) <EOL> def test_translate_reservation_from_data_waiting ( self ) : <EOL> reservation = Reservation . translate_reservation_from_data ( Reservation . WAITING , '<STR_LIT:foo>' , <NUM_LIT:5> , None , None , None , None , None , None , None ) <EOL> self . assertEquals ( Reservation . WAITING , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( <NUM_LIT:5> , reservation . position ) <EOL> def test_translate_reservation_from_data_waiting_confirmation ( self ) : <EOL> reservation = Reservation . translate_reservation_from_data ( Reservation . WAITING_CONFIRMATION , '<STR_LIT:foo>' , None , None , None , None , '<STR_LIT>' , None , None , None ) <EOL> self . assertEquals ( Reservation . WAITING_CONFIRMATION , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( '<STR_LIT>' , reservation . url ) <EOL> def test_translate_reservation_from_data_waiting_instances ( self ) : <EOL> reservation = Reservation . translate_reservation_from_data ( Reservation . WAITING_INSTANCES , '<STR_LIT:foo>' , <NUM_LIT:5> , None , None , None , None , None , None , None ) <EOL> self . assertEquals ( Reservation . WAITING_INSTANCES , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( <NUM_LIT:5> , reservation . position ) <EOL> def test_translate_reservation_from_data_confirmed ( self ) : <EOL> reservation = Reservation . translate_reservation_from_data ( Reservation . CONFIRMED , '<STR_LIT:foo>' , None , <NUM_LIT> , "<STR_LIT:{}>" , None , '<STR_LIT>' , None , None , '<STR_LIT>' ) <EOL> self . assertEquals ( Reservation . CONFIRMED , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( '<STR_LIT>' , reservation . url ) <EOL> self . assertEquals ( '<STR_LIT:{}>' , reservation . initial_configuration ) <EOL> def test_translate_reservation_from_data_confirmed_remote ( self ) : <EOL> reservation = Reservation . translate_reservation_from_data ( Reservation . CONFIRMED , '<STR_LIT:foo>' , None , <NUM_LIT> , "<STR_LIT:{}>" , None , '<STR_LIT>' , None , None , '<STR_LIT:bar>' ) <EOL> self . assertEquals ( Reservation . CONFIRMED , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( '<STR_LIT>' , reservation . url ) <EOL> self . assertEquals ( '<STR_LIT:{}>' , reservation . initial_configuration ) <EOL> self . assertEquals ( '<STR_LIT:bar>' , reservation . remote_reservation_id . id ) <EOL> def test_translate_reservation_from_data_post_reservation ( self ) : <EOL> reservation = Reservation . translate_reservation_from_data ( Reservation . POST_RESERVATION , '<STR_LIT:foo>' , None , None , None , "<STR_LIT:{}>" , None , True , "<STR_LIT>" , None ) <EOL> self . assertEquals ( Reservation . POST_RESERVATION , reservation . status ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , reservation . reservation_id . id ) <EOL> self . assertEquals ( '<STR_LIT>' , reservation . initial_data ) <EOL> self . assertEquals ( '<STR_LIT:{}>' , reservation . end_data ) <EOL> self . assertTrue ( reservation . finished ) <EOL> def suite ( ) : <EOL> return unittest . makeSuite ( ReservationTest ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
