<s> from __future__ import print_function , unicode_literals <EOL> import unittest <EOL> import test . unit . configuration as configuration_module <EOL> import voodoo . configuration as ConfigurationManager <EOL> import weblab . core . exc as coreExc <EOL> from weblab . data . experiments import ExperimentInstanceId <EOL> from weblab . core . coordinator . resource import Resource <EOL> import weblab . core . coordinator . config_parser as CoordinationConfigurationParser <EOL> class CoordinationConfigurationParserTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . cfg_manager = ConfigurationManager . ConfigurationManager ( ) <EOL> self . cfg_manager . append_module ( configuration_module ) <EOL> self . coordination_configuration_parser = CoordinationConfigurationParser . CoordinationConfigurationParser ( self . cfg_manager ) <EOL> def test_coordination_configuration_parser ( self ) : <EOL> self . cfg_manager . _set_value ( CoordinationConfigurationParser . COORDINATOR_LABORATORY_SERVERS , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> } ) <EOL> configuration = self . coordination_configuration_parser . parse_configuration ( ) <EOL> self . assertEquals ( <NUM_LIT:1> , len ( configuration ) ) <EOL> lab_config = configuration [ '<STR_LIT>' ] <EOL> self . assertEquals ( <NUM_LIT:2> , len ( lab_config ) ) <EOL> exp_fpga = ExperimentInstanceId ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> exp_pld = ExperimentInstanceId ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> fpga_resource = lab_config [ exp_fpga ] <EOL> self . assertEquals ( Resource ( "<STR_LIT>" , "<STR_LIT>" ) , fpga_resource ) <EOL> pld_resource = lab_config [ exp_pld ] <EOL> self . assertEquals ( Resource ( "<STR_LIT>" , "<STR_LIT>" ) , pld_resource ) <EOL> def test_coordination_parse_resources_for_experiment_ids ( self ) : <EOL> self . cfg_manager . _set_value ( CoordinationConfigurationParser . COORDINATOR_LABORATORY_SERVERS , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } , <EOL> } ) <EOL> self . cfg_manager . _set_value ( CoordinationConfigurationParser . COORDINATOR_EXTERNAL_SERVERS , { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } ) <EOL> configuration = self . coordination_configuration_parser . parse_resources_for_experiment_ids ( ) <EOL> self . assertTrue ( '<STR_LIT>' in configuration ) <EOL> self . assertTrue ( '<STR_LIT>' in configuration ) <EOL> self . assertTrue ( '<STR_LIT>' in configuration ) <EOL> self . assertEquals ( set ( ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) , configuration [ '<STR_LIT>' ] ) <EOL> self . assertEquals ( set ( ( '<STR_LIT>' , ) ) , configuration [ '<STR_LIT>' ] ) <EOL> self . assertEquals ( set ( ( '<STR_LIT>' , ) ) , configuration [ '<STR_LIT>' ] ) <EOL> self . assertEquals ( set ( ( '<STR_LIT>' , '<STR_LIT>' ) ) , configuration [ '<STR_LIT>' ] ) <EOL> def test_coordination_configuration_parser_fail1 ( self ) : <EOL> self . cfg_manager . _set_value ( CoordinationConfigurationParser . COORDINATOR_LABORATORY_SERVERS , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } , <EOL> } ) <EOL> self . assertRaises ( <EOL> coreExc . CoordinationConfigurationParsingError , <EOL> self . coordination_configuration_parser . parse_configuration <EOL> ) <EOL> def test_coordination_configuration_parser_fail2 ( self ) : <EOL> self . cfg_manager . _set_value ( CoordinationConfigurationParser . COORDINATOR_LABORATORY_SERVERS , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> } ) <EOL> self . assertRaises ( <EOL> coreExc . CoordinationConfigurationParsingError , <EOL> self . coordination_configuration_parser . parse_configuration <EOL> ) <EOL> def suite ( ) : <EOL> return unittest . makeSuite ( CoordinationConfigurationParserTestCase ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
