Exemplo n.º 1
0
    def test_createset(self):
        """Test success path for Types.create_set()"""
        types = Types()
        types.create_set(['osd', 'host', 'root'])

        t = types.get_type(name='osd')
        assert 0 == t.id
        assert 'osd' == t.name

        t = types.get_type(name='host')
        assert 1 == t.id
        assert 'host' == t.name

        t = types.get_type(name='root')
        assert 2 == t.id
        assert 'root' == t.name

        assert 3 == len(types.get_type())
Exemplo n.º 2
0
 def test_types_repr(self):
     types = Types()
     types.create_set(['osd', 'host', 'root'])
     assert repr(types) == '<Types [0: osd, 1: host, 2: root]>'
     assert repr(types.get_type('osd')) == '<Type name=osd id=0>'
Exemplo n.º 3
0
    def test_createset_except(self):
        """Test exceptions returned by Types.create_set()"""
        types = Types()
        with pytest.raises(TypeError):
            types.create_set('71Li212')
        with pytest.raises(TypeError):
            types.create_set(['osd', 1234, 'root'])
        with pytest.raises(ValueError):
            types.create_set([])
        with pytest.raises(ValueError):
            types.create_set(['osd', 'osd', 'host'])

        types.create_set(['osd', 'host', 'root'])
        with pytest.raises(IndexError):
            types.create_set([])