def test_get_except(self): """Test exceptions returned by Types.get_type()""" types = Types() with pytest.raises(TypeError): types.get_type(name=71) with pytest.raises(TypeError): types.get_type(type_id="string") with pytest.raises(ValueError): types.get_type(name="") types.add_type('osd', 0) with pytest.raises(ValueError): types.get_type(name='osd', type_id=0) with pytest.raises(IndexError): types.get_type(type_id=1)
def test_get(self): """Test success path for Types.get_type()""" types = Types() types.add_type("host", 0) types.add_type("root", 3) assert isinstance(types.get_type(type_id=0), Type) host = types.get_type(type_id=0) assert 0 == host.id assert 'host' == host.name host = types.get_type(name='host') assert 0 == host.id assert 'host' == host.name assert types.get_type(type_id=3) in types.get_type()
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())
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>'