def test_nested(): Top = xmlfied('top', foo=Nested()) Down = xmlfied('down', bar=Element(), baz=Attribute()) d = Down(bar='123', baz='456') t = Top(foo=d) assert_that( etree.tostring(t.toxml()), string_contains_in_order('<top>', '<down', 'baz=', '"456"', '<bar>', '123', '</bar>', '</down>', '</top>'))
class Environment( xmlfied('environment', namespace=COMMON_NAMESPACE, id=Element(), name=Element(), parameters=Many(Nested()))): pass
def test_element_name(): foo = xmlfied('foo', bar=Element(name='foo-bar')) assert_that( etree.tostring(foo(bar='123').toxml()), string_contains_in_order('<foo>', '<foo-bar>', '123', '</foo-bar>', '</foo>'))
def test_bad_symbols_replacement(): foo = xmlfied('foo', bar=Element(name='bar')) assert_that( etree.tostring(foo(bar=u'abОЛОЛОcd'.encode('cp1251')).toxml()), string_contains_in_order('<bar>', 'ab', '�' * 4, 'cd', '</bar>'))
def test_attribute(): AttrTest = xmlfied('attr_test', foo=Attribute()) a = AttrTest(foo='bar') assert_that(etree.tostring(a.toxml()), string_contains_in_order('<attr_test', 'foo=', '"bar"', ">"))
def test_many_nested(): Item = xmlfied('item', value=Element()) Box = xmlfied('box', items=WrappedMany(Nested())) box = Box(items=[]) box.items.append(Item('a')) box.items.append(Item('a')) box.items.append(Item('a')) assert_that( etree.tostring(box.toxml()), all_of( string_contains_in_order('<box>', '<items>', '<item>', 'a', '</item>', '<item>', 'a', '</item>', '<item>', 'a', '</item>', '</items>', '</box>'), ))
def test_optional(): foo = xmlfied('foo', bar=Element().if_(lambda x: '123' not in x)) assert_that(etree.tostring(foo(bar=' 123 ').toxml()), string_contains_in_order('<foo/>')) assert_that(etree.tostring(foo(bar=' 12 3').toxml()), string_contains_in_order('<foo>', '<bar>'))
def test_element(): ElementTest = xmlfied('element_test', ab=Element()) a = ElementTest(ab='foo') assert_that(get_xml_string(a.toxml()), string_contains_in_order('<element_test>', '<ab>foo</ab>', '</element_test>'))
def test_nested(): Top = xmlfied('top', foo=Nested()) Down = xmlfied('down', bar=Element(), baz=Attribute()) d = Down(bar='123', baz='456') t = Top(foo=d) assert_that(etree.tostring(t.toxml()), string_contains_in_order( '<top>', '<down', 'baz=', '"456"', '<bar>', '123', '</bar>', '</down>', '</top>' ))
def test_many_nested(): Item = xmlfied('item', value=Element()) Box = xmlfied('box', items=Many(Nested())) box = Box(items=[]) box.items.append(Item('a')) box.items.append(Item('a')) box.items.append(Item('a')) assert_that(etree.tostring(box.toxml()), all_of( string_contains_in_order('<box>', '<items>', '<item>', 'a', '</item>', '<item>', 'a', '</item>', '<item>', 'a', '</item>', '</items>', '</box>'), ))
class TestStep(IterAttachmentsMixin, xmlfied('step', name=Element(), title=Element().if_(lambda x: x), attachments=WrappedMany(Nested()), steps=WrappedMany(Nested()), start=Attribute(), stop=Attribute(), status=Attribute())): pass
def test_many_elements(): Box = xmlfied('box', foos=Many(Element(name='foo'))) box = Box(foos=['a', 'b', 'c']) assert_that(etree.tostring(box.toxml()), all_of( string_contains_in_order('<box>', '<foos>', '<foo>', 'a', '</foo>', '</foos>', '</box>'), string_contains_in_order('<box>', '<foos>', '<foo>', 'b', '</foo>', '</foos>', '</box>'), string_contains_in_order('<box>', '<foos>', '<foo>', 'c', '</foo>', '</foos>', '</box>') ))
def test_many_elements(): Box = xmlfied('box', foos=WrappedMany(Element(name='foo'))) box = Box(foos=['a', 'b', 'c']) assert_that(get_xml_string(box.toxml()), all_of( string_contains_in_order('<box>', '<foos>', '<foo>', 'a', '</foo>', '</foos>', '</box>'), string_contains_in_order('<box>', '<foos>', '<foo>', 'b', '</foo>', '</foos>', '</box>'), string_contains_in_order('<box>', '<foos>', '<foo>', 'c', '</foo>', '</foos>', '</box>') ))
class TestSuite( xmlfied('test-suite', namespace=ALLURE_NAMESPACE, name=Element(), title=Element().if_(lambda x: x), description=Element().if_(lambda x: x), tests=WrappedMany(Nested(), name='test-cases'), labels=WrappedMany(Nested()), start=Attribute(), stop=Attribute())): pass
def test_elements_order(): Foo = xmlfied('foo', fields=[('bar', Element()), ('baz', Element()), ('gaz', Element()), ('daz', Element())]) foo = Foo(bar=3, baz=4, gaz=5, daz=6) assert_that( etree.tostring(foo.toxml()), string_contains_in_order('<bar>', '3', '</bar>', '<baz>', '4', '</baz>', '<gaz>', '5', '</gaz>', '<daz>', '6', '</daz>'))
def test_elements_order(): Foo = xmlfied('foo', fields=[ ('bar', Element()), ('baz', Element()), ('gaz', Element()), ('daz', Element())]) foo = Foo(bar=3, baz=4, gaz=5, daz=6) assert_that(etree.tostring(foo.toxml()), string_contains_in_order( '<bar>', '3', '</bar>', '<baz>', '4', '</baz>', '<gaz>', '5', '</gaz>', '<daz>', '6', '</daz>' ))
class TestCase( IterAttachmentsMixin, xmlfied( 'test-case', id=Ignored(), # internal field, see AllureTestListener name=Element(), title=Element().if_(lambda x: x), description=Element().if_(lambda x: x), failure=Nested().if_(lambda x: x), steps=WrappedMany(Nested()), attachments=WrappedMany(Nested()), labels=WrappedMany(Nested()), status=Attribute(), start=Attribute(), stop=Attribute())): pass
''' This holds allure report xml structures Created on Oct 23, 2013 @author: pupssman ''' from allure.rules import xmlfied, Attribute, Element, WrappedMany, Nested, Many from allure.constants import ALLURE_NAMESPACE, COMMON_NAMESPACE Attach = xmlfied('attachment', source=Attribute(), title=Attribute(), type=Attribute()) Failure = xmlfied('failure', message=Element(), trace=Element('stack-trace')) TestCase = xmlfied('test-case', name=Element(), title=Element().if_(lambda x: x), description=Element().if_(lambda x: x), failure=Nested().if_(lambda x: x), steps=WrappedMany(Nested()), attachments=WrappedMany(Nested()), labels=WrappedMany(Nested()), status=Attribute(), start=Attribute(), stop=Attribute()) TestSuite = xmlfied('test-suite',
def test_element_name(): foo = xmlfied('foo', bar=Element(name='foo-bar')) assert_that(etree.tostring(foo(bar='123').toxml()), string_contains_in_order('<foo>', '<foo-bar>', '123', '</foo-bar>', '</foo>'))
def test_bad_symbols_replacement(): foo = xmlfied('foo', bar=Element(name='bar')) assert_that(etree.tostring(foo(bar=u'abОЛОЛОcd'.encode('cp1251')).toxml()), string_contains_in_order('<bar>', 'ab', '�' * 4, 'cd', '</bar>'))
def test_illegal_xml_symbols(): foo = xmlfied('foo', bar=Element(name='bar')) foo(bar=''.join(map(chr, range(128)))).toxml()
class Failure( xmlfied('failure', message=Element(), trace=Element('stack-trace'))): """
''' This holds allure report xml structures Created on Oct 23, 2013 @author: pupssman ''' from allure.rules import xmlfied, Attribute, Element, Many, Nested from allure.constants import ALLURE_NAMESPACE Attach = xmlfied('attachment', source=Attribute(), title=Attribute(), type=Attribute()) Failure = xmlfied('failure', message=Element(), trace=Element('stack-trace')) TestCase = xmlfied('test-case', name=Element(), title=Element().if_(lambda x: x), description=Element().if_(lambda x: x), failure=Nested().if_(lambda x: x), steps=Many(Nested()), attachments=Many(Nested()), labels=Many(Nested()),
class EnvParameter( xmlfied('parameter', name=Element(), key=Element(), value=Element())): pass
class TestLabel(xmlfied('label', name=Attribute(), value=Attribute())): pass
class Attach( xmlfied('attachment', source=Attribute(), title=Attribute(), type=Attribute())): """
''' This holds allure report xml structures Created on Oct 23, 2013 @author: pupssman ''' from allure.rules import xmlfied, Attribute, Element, Many, Nested from allure.constants import ALLURE_NAMESPACE Attach = xmlfied('attachment', source=Attribute(), title=Attribute(), type=Attribute()) Failure = xmlfied('failure', message=Element(), trace=Element('stack-trace')) TestCase = xmlfied('test-case', name=Element(), title=Element().if_(lambda x: x), description=Element().if_(lambda x: x), failure=Nested().if_(lambda x: x), steps=Many(Nested()), attachments=Many(Nested()), labels=Many(Nested()), status=Attribute(), start=Attribute(), stop=Attribute(), severity=Attribute())
''' This holds allure report xml structures Created on Oct 23, 2013 @author: pupssman ''' from allure.rules import xmlfied, Attribute, Element, WrappedMany, Nested, Many from allure.constants import ALLURE_NAMESPACE, COMMON_NAMESPACE Attach = xmlfied('attachment', source=Attribute(), title=Attribute(), type=Attribute()) Failure = xmlfied('failure', message=Element(), trace=Element('stack-trace')) TestCase = xmlfied('test-case', name=Element(), title=Element().if_(lambda x: x), description=Element().if_(lambda x: x), failure=Nested().if_(lambda x: x), steps=WrappedMany(Nested()), attachments=WrappedMany(Nested()), labels=WrappedMany(Nested()),