Exemplo n.º 1
0
 def test_unknown_dict(self):
     """Test type parsing with a dict without keytype."""
     data = self._yaml("type: Dict")
     with pytest.raises(ValueError,
                        match="Invalid node for test while "
                        "reading 'keytype': 'Dict'"):
         configdata._parse_yaml_type('test', data)
Exemplo n.º 2
0
 def test_invalid_node(self):
     """Test type parsing with invalid node type."""
     data = self._yaml("type: 42")
     with pytest.raises(ValueError,
                        match="Invalid node for test while "
                        "reading type: 42"):
         configdata._parse_yaml_type('test', data)
Exemplo n.º 3
0
 def test_unknown_args(self):
     """Test type parsing with unknown type arguments."""
     data = self._yaml("""
         type:
           name: Int
           answer: 42
     """)
     with pytest.raises(TypeError, match="Error while creating Int"):
         configdata._parse_yaml_type('test', data)
Exemplo n.º 4
0
 def test_unknown_args(self):
     """Test type parsing with unknown type arguments."""
     data = self._yaml("""
         type:
           name: Int
           answer: 42
     """)
     with pytest.raises(TypeError, match="Error while creating Int"):
         configdata._parse_yaml_type('test', data)
Exemplo n.º 5
0
 def test_complex(self):
     """Test type parsing with arguments."""
     data = self._yaml("""
         type:
           name: String
           minlen: 2
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.String)
     assert not typ.none_ok
     assert typ.minlen == 2
Exemplo n.º 6
0
 def test_complex(self):
     """Test type parsing with arguments."""
     data = self._yaml("""
         type:
           name: String
           minlen: 2
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.String)
     assert not typ.none_ok
     assert typ.minlen == 2
Exemplo n.º 7
0
 def test_list(self):
     """Test type parsing with a list and subtypes."""
     data = self._yaml("""
         type:
           name: List
           valtype: String
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.List)
     assert isinstance(typ.valtype, configtypes.String)
     assert not typ.none_ok
     assert not typ.valtype.none_ok
Exemplo n.º 8
0
 def test_list(self):
     """Test type parsing with a list and subtypes."""
     data = self._yaml("""
         type:
           name: List
           valtype: String
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.List)
     assert isinstance(typ.valtype, configtypes.String)
     assert not typ.none_ok
     assert not typ.valtype.none_ok
Exemplo n.º 9
0
 def test_dict(self):
     """Test type parsing with a dict and subtypes."""
     data = self._yaml("""
         type:
           name: Dict
           keytype: String
           valtype:
             name: Int
             minval: 10
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.Dict)
     assert isinstance(typ.keytype, configtypes.String)
     assert isinstance(typ.valtype, configtypes.Int)
     assert not typ.none_ok
     assert typ.valtype.minval == 10
Exemplo n.º 10
0
 def test_dict(self):
     """Test type parsing with a dict and subtypes."""
     data = self._yaml("""
         type:
           name: Dict
           keytype: String
           valtype:
             name: Int
             minval: 10
     """)
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.Dict)
     assert isinstance(typ.keytype, configtypes.String)
     assert isinstance(typ.valtype, configtypes.Int)
     assert not typ.none_ok
     assert typ.valtype.minval == 10
Exemplo n.º 11
0
 def test_unknown_type(self):
     """Test type parsing with type which doesn't exist."""
     data = self._yaml("type: Foobar")
     with pytest.raises(AttributeError,
                        match="Did not find type Foobar for test"):
         configdata._parse_yaml_type('test', data)
Exemplo n.º 12
0
 def test_simple(self):
     """Test type which is only a name."""
     data = self._yaml("type: Bool")
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.Bool)
     assert not typ.none_ok
Exemplo n.º 13
0
 def test_unknown_dict(self):
     """Test type parsing with a dict without keytype."""
     data = self._yaml("type: Dict")
     with pytest.raises(ValueError, match="Invalid node for test while "
                                          "reading 'keytype': 'Dict'"):
         configdata._parse_yaml_type('test', data)
Exemplo n.º 14
0
 def test_unknown_type(self):
     """Test type parsing with type which doesn't exist."""
     data = self._yaml("type: Foobar")
     with pytest.raises(AttributeError,
                        match="Did not find type Foobar for test"):
         configdata._parse_yaml_type('test', data)
Exemplo n.º 15
0
 def test_invalid_node(self):
     """Test type parsing with invalid node type."""
     data = self._yaml("type: 42")
     with pytest.raises(ValueError, match="Invalid node for test while "
                                          "reading type: 42"):
         configdata._parse_yaml_type('test', data)
Exemplo n.º 16
0
 def test_simple(self):
     """Test type which is only a name."""
     data = self._yaml("type: Bool")
     typ = configdata._parse_yaml_type('test', data)
     assert isinstance(typ, configtypes.Bool)
     assert not typ.none_ok