def test_lists(self): info = ComponentInfo(_VALID_PARAMS) self.assertListEqual(["mapper1", "mapper2"], info["mappers"]) self.assertListEqual(["one_port", "two_ports"], info["ports"]) self.assertListEqual(["one_port"], info["optional_ports"]) self.assertListEqual(["two_ports"], info["init_ports"])
def test_from_list(self): params = _VALID_PARAMS info = ComponentInfo(params.items()) self.assertEqual(len(params), info.size) self.assertSetEqual(set(params), info.params) for key in _VALID_PARSED_PARAMS: self.assertEqual(_VALID_PARSED_PARAMS[key], info[key])
def test_lists(self): info = ComponentInfo(_VALID_PARAMS) self.assertListEqual(['mapper1', 'mapper2'], info['mappers']) self.assertListEqual(['one_port', 'two_ports'], info['ports']) self.assertListEqual([ 'one_port', ], info['optional_ports']) self.assertListEqual([ 'two_ports', ], info['init_ports'])
def test_leading_whitespace(self): params = _VALID_PARAMS.copy() params['output_file_namespace'] = ' /Component/Info' info = ComponentInfo(params) self.assertEqual('/Component/Info', info['output_file_namespace'])
def test_mappings(self): info = ComponentInfo(_VALID_PARAMS) self.assertDictEqual({'file.txt.in': 'file.txt'}, info['template_files'])
def test_floats(self): info = ComponentInfo(_VALID_PARAMS) self.assertEqual(2., info['port_queue_dt'])
def test_unknown_key(self): params = _VALID_PARAMS.copy() params['unknown_key'] = 'unexpected key' with self.assertRaises(UnknownKeyError): info = ComponentInfo(params)
def test_missing_key(self): for key in _VALID_PARAMS: params = _VALID_PARAMS.copy() params.pop(key) with self.assertRaises(MissingKeyError): info = ComponentInfo(params)
def test_whitespace_in_mappings(self): params = _VALID_PARAMS.copy() params['template_files'] = '\n file.txt.in -> \n\tfile.txt\n\n ' info = ComponentInfo(params) self.assertDictEqual({'file.txt.in': 'file.txt'}, info['template_files'])
def test_whitespace_in_lists(self): params = _VALID_PARAMS.copy() params['ports'] = ' port1 , port2, \tport 3\n\n\n' info = ComponentInfo(params) self.assertListEqual(['port1', 'port2', 'port 3'], info['ports'])
def test_whitespace_in_lists(self): params = _VALID_PARAMS.copy() params["ports"] = " port1 , port2, \tport 3\n\n\n" info = ComponentInfo(params) self.assertListEqual(["port1", "port2", "port 3"], info["ports"])
def test_trailing_whitespace(self): params = _VALID_PARAMS.copy() params["output_file_namespace"] = "/Component/Info \n " info = ComponentInfo(params) self.assertEqual("/Component/Info", info["output_file_namespace"])
def test_mappings(self): info = ComponentInfo(_VALID_PARAMS) self.assertDictEqual({"file.txt.in": "file.txt"}, info["template_files"])
def test_unknown_key(self): params = _VALID_PARAMS.copy() params["unknown_key"] = "unexpected key" with self.assertRaises(UnknownKeyError): ComponentInfo(params)
def test_whitespace_in_mappings(self): params = _VALID_PARAMS.copy() params["template_files"] = "\n file.txt.in -> \n\tfile.txt\n\n " info = ComponentInfo(params) self.assertDictEqual({"file.txt.in": "file.txt"}, info["template_files"])