Esempio n. 1
0
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>'))
Esempio n. 2
0
class Environment(
        xmlfied('environment',
                namespace=COMMON_NAMESPACE,
                id=Element(),
                name=Element(),
                parameters=Many(Nested()))):
    pass
Esempio n. 3
0
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>'))
Esempio n. 4
0
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', '&#65533;' * 4, 'cd',
                                 '</bar>'))
Esempio n. 5
0
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"', ">"))
Esempio n. 6
0
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>'), ))
Esempio n. 7
0
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>'))
Esempio n. 8
0
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>'))
Esempio n. 9
0
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>'
    ))
Esempio n. 10
0
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>'),
    ))
Esempio n. 11
0
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
Esempio n. 12
0
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>')
    ))
Esempio n. 13
0
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>')
    ))
Esempio n. 14
0
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
Esempio n. 15
0
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>'))
Esempio n. 16
0
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>'
    ))
Esempio n. 17
0
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
Esempio n. 18
0
'''
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',
Esempio n. 19
0
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>'))
Esempio n. 20
0
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>'))
Esempio n. 21
0
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', '&#65533;' * 4, 'cd', '</bar>'))
Esempio n. 22
0
def test_illegal_xml_symbols():
    foo = xmlfied('foo', bar=Element(name='bar'))

    foo(bar=''.join(map(chr, range(128)))).toxml()
Esempio n. 23
0
class Failure(
        xmlfied('failure', message=Element(), trace=Element('stack-trace'))):
    """
Esempio n. 24
0
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"', ">"))
Esempio n. 25
0
'''
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()),
Esempio n. 26
0
class EnvParameter(
        xmlfied('parameter', name=Element(), key=Element(), value=Element())):
    pass
Esempio n. 27
0
class TestLabel(xmlfied('label', name=Attribute(), value=Attribute())):
    pass
Esempio n. 28
0
class Attach(
        xmlfied('attachment',
                source=Attribute(),
                title=Attribute(),
                type=Attribute())):
    """
Esempio n. 29
0
'''
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())
Esempio n. 30
0
'''
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()),
Esempio n. 31
0
def test_illegal_xml_symbols():
    foo = xmlfied('foo', bar=Element(name='bar'))

    foo(bar=''.join(map(chr, range(128)))).toxml()