def test_references(): root = RootFixture() enc = EnclosedFixture() enc._parent = root enc.id = 'reftest1' assert root.find_reference('reftest1') == enc with pytest.raises(ReferenceException): root.find_reference('test1')
def test_references(): root = RootFixture() #TODO need to add to a attr mapper knows about enc = EnclosedFixture() enc.id = 'reftest1' root.EnclosedFixture = enc assert root.find_reference('reftest1') == enc with pytest.raises(ReferenceException): root.find_reference('test1')
def test_produce_list_class(): model = ListElementFixture(local_name='ListElementFixture', namespace='http://jaymes.biz/test', prefix='test') model.list_class.append( EnclosedFixture(value='test1', local_name='list_class')) model.list_class.append( EnclosedFixture(value='test2', local_name='list_class')) xml = model.produce().produce() assert xml.startswith('<test:ListElementFixture') assert 'xmlns:test="http://jaymes.biz/test"' in xml assert '<test:list_class>test1</test:list_class>' in xml assert '<test:list_class>test2</test:list_class>' in xml
def test_produce_root_enclosed(): model = RootFixture(local_name='RootFixture', namespace='http://jaymes.biz/test', prefix='test') model.EnclosedFixture = EnclosedFixture(local_name='EnclosedFixture') assert model.produce().produce() == \ '<test:RootFixture xmlns:test="http://jaymes.biz/test"><test:EnclosedFixture/></test:RootFixture>'
def test_produce_list_nil(): model = ListElementFixture(local_name='ListElementFixture', namespace='http://jaymes.biz/test', prefix='test') model.list_nil.append(None) model.list_nil.append(EnclosedFixture(value='test', local_name='list_nil')) xml = model.produce().produce() assert xml.startswith('<test:ListElementFixture') assert 'xmlns:test="http://jaymes.biz/test"' in xml assert '<test:list_nil xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>' in xml assert '<test:list_nil>test</test:list_nil>' in xml
def test_produce_wildcard_in(): model = WildcardElementInFixture(local_name='WildcardElementInFixture', namespace='http://jaymes.biz/test', prefix='test') model.test_elements.append(EnclosedFixture(local_name='wildcard_element')) model.elements.append(EnclosedFixture2(local_name='wildcard_element')) xml = model.produce().produce() assert xml.startswith('<test:WildcardElementInFixture') assert 'xmlns:test="http://jaymes.biz/test"' in xml assert 'xmlns:test2="http://jaymes.biz/test2"' in xml assert '<test:wildcard_element' in xml assert '<test2:wildcard_element' in xml
def test_produce_min_max(): model = MinMaxElementFixture(local_name='MinMaxElementFixture', namespace='http://jaymes.biz/test', prefix='test') for i in range(0, 3): model.min.append(EnclosedFixture(local_name='min')) for i in range(0, 2): model.max.append(EnclosedFixture(local_name='max')) xml = model.produce().produce() assert xml.startswith( '<test:MinMaxElementFixture xmlns:test="http://jaymes.biz/test"') assert xml.count('<test:min') == 3 assert xml.count('<test:max') == 2 del model.min[0] with pytest.raises(MinimumElementException): model.produce() model.min.append(EnclosedFixture()) model.max.append(EnclosedFixture()) with pytest.raises(MaximumElementException): model.produce()
def test_children_attr(): model = RootFixture() model.EnclosedFixture = EnclosedFixture() assert model._children == [('EnclosedFixture', None)]