<s> from __future__ import print_function , unicode_literals <EOL> import unittest <EOL> import weblab . lab . exc as LaboratoryErrors <EOL> import weblab . lab . assigned_experiments as AssignedExperiments <EOL> from voodoo . gen import CoordAddress <EOL> from weblab . data . experiments import ExperimentInstanceId <EOL> class AssignedExperimentsTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . _assigned_micro_servers = AssignedExperiments . AssignedExperiments ( ) <EOL> self . exp_inst_id = ExperimentInstanceId ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_add_server ( self ) : <EOL> clients_coord_addresses = CoordAddress . translate ( "<STR_LIT>" ) <EOL> checking_handlers = ( '<STR_LIT>' , ) <EOL> self . _assigned_micro_servers . add_server ( self . exp_inst_id , clients_coord_addresses , { '<STR_LIT>' : checking_handlers } ) <EOL> self . assertRaises ( <EOL> LaboratoryErrors . ExperimentAlreadyFoundError , <EOL> self . _assigned_micro_servers . add_server , <EOL> self . exp_inst_id , <EOL> clients_coord_addresses , <EOL> { '<STR_LIT>' : checking_handlers } <EOL> ) <EOL> def test_list_experiment_instance_ids ( self ) : <EOL> clients_coord_addresses = CoordAddress . translate ( "<STR_LIT>" ) <EOL> checking_handlers = ( '<STR_LIT>' , ) <EOL> self . _assigned_micro_servers . add_server ( self . exp_inst_id , clients_coord_addresses , { '<STR_LIT>' : checking_handlers } ) <EOL> result = self . _assigned_micro_servers . list_experiment_instance_ids ( ) <EOL> self . assertEquals ( [ self . exp_inst_id ] , result ) <EOL> def test_get_coord_address ( self ) : <EOL> clients_coord_addresses = CoordAddress . translate ( "<STR_LIT>" ) <EOL> checking_handlers = ( '<STR_LIT>' , ) <EOL> self . _assigned_micro_servers . add_server ( self . exp_inst_id , clients_coord_addresses , { '<STR_LIT>' : checking_handlers } ) <EOL> coord_address = self . _assigned_micro_servers . get_coord_address ( self . exp_inst_id ) <EOL> self . assertEquals ( clients_coord_addresses , coord_address ) <EOL> def test_get_lab_session_id ( self ) : <EOL> clients_coord_addresses = CoordAddress . translate ( "<STR_LIT>" ) <EOL> checking_handlers = ( '<STR_LIT>' , ) <EOL> self . _assigned_micro_servers . add_server ( self . exp_inst_id , clients_coord_addresses , { '<STR_LIT>' : checking_handlers } ) <EOL> self . _assigned_micro_servers . reserve_experiment ( self . exp_inst_id , "<STR_LIT:foo>" ) <EOL> lab_session_id = self . _assigned_micro_servers . get_lab_session_id ( self . exp_inst_id ) <EOL> self . assertEquals ( "<STR_LIT:foo>" , lab_session_id ) <EOL> def test_get_is_up_and_running_handlers ( self ) : <EOL> clients_coord_addresses = CoordAddress . translate ( "<STR_LIT>" ) <EOL> checking_handlers = ( '<STR_LIT>' , ) <EOL> self . _assigned_micro_servers . add_server ( self . exp_inst_id , clients_coord_addresses , { '<STR_LIT>' : checking_handlers } ) <EOL> retrieved_is_up_and_running_handlers = self . _assigned_micro_servers . get_is_up_and_running_handlers ( self . exp_inst_id ) <EOL> self . assertEquals ( checking_handlers , retrieved_is_up_and_running_handlers ) <EOL> def test_reserve_experiment ( self ) : <EOL> clients_coord_addresses = CoordAddress . translate ( "<STR_LIT>" ) <EOL> checking_handlers = ( '<STR_LIT>' , ) <EOL> self . _assigned_micro_servers . add_server ( self . exp_inst_id , clients_coord_addresses , { '<STR_LIT>' : checking_handlers } ) <EOL> def check_reserve ( ) : <EOL> result = self . _assigned_micro_servers . reserve_experiment ( self . exp_inst_id , "<STR_LIT>" ) <EOL> self . assertEquals ( clients_coord_addresses , result ) <EOL> check_reserve ( ) <EOL> self . _assigned_micro_servers . free_experiment ( self . exp_inst_id ) <EOL> check_reserve ( ) <EOL> self . _assigned_micro_servers . free_experiment ( self . exp_inst_id ) <EOL> self . assertRaises ( <EOL> LaboratoryErrors . AlreadyFreedExperimentError , <EOL> self . _assigned_micro_servers . free_experiment , <EOL> self . exp_inst_id <EOL> ) <EOL> def test_bounds ( self ) : <EOL> self . assertRaises ( <EOL> LaboratoryErrors . ExperimentNotFoundError , <EOL> self . _assigned_micro_servers . reserve_experiment , <EOL> self . exp_inst_id , <EOL> "<STR_LIT>" <EOL> ) <EOL> def suite ( ) : <EOL> return unittest . makeSuite ( AssignedExperimentsTestCase ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
