コード例 #1
0
    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"])
コード例 #2
0
    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])
コード例 #3
0
    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'])
コード例 #4
0
 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'])
コード例 #5
0
 def test_mappings(self):
     info = ComponentInfo(_VALID_PARAMS)
     self.assertDictEqual({'file.txt.in': 'file.txt'},
                          info['template_files'])
コード例 #6
0
 def test_floats(self):
     info = ComponentInfo(_VALID_PARAMS)
     self.assertEqual(2., info['port_queue_dt'])
コード例 #7
0
 def test_unknown_key(self):
     params = _VALID_PARAMS.copy()
     params['unknown_key'] = 'unexpected key'
     with self.assertRaises(UnknownKeyError):
         info = ComponentInfo(params)
コード例 #8
0
 def test_missing_key(self):
     for key in _VALID_PARAMS:
         params = _VALID_PARAMS.copy()
         params.pop(key)
         with self.assertRaises(MissingKeyError):
             info = ComponentInfo(params)
コード例 #9
0
 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'])
コード例 #10
0
 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'])
コード例 #11
0
 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"])
コード例 #12
0
 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"])
コード例 #13
0
 def test_mappings(self):
     info = ComponentInfo(_VALID_PARAMS)
     self.assertDictEqual({"file.txt.in": "file.txt"},
                          info["template_files"])
コード例 #14
0
 def test_unknown_key(self):
     params = _VALID_PARAMS.copy()
     params["unknown_key"] = "unexpected key"
     with self.assertRaises(UnknownKeyError):
         ComponentInfo(params)
コード例 #15
0
 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"])