def _assert_object_types(self, put: unittest.TestCase, value: Node,
                          message_builder: MessageBuilder):
     put.assertIsInstance(value, Node,
                          message_builder.apply('Node object type'))
     self._HEADER_IS_STR.apply(put, value, message_builder)
     self._IS_SEQUENCE_OF_DETAIL.apply(put, value.details, message_builder)
     asrt.every_element('children',
                        matches_node()).apply(put, value.children,
                                              message_builder)
Ejemplo n.º 2
0
    def visit_table(self, table: Table):
        format_assertion = asrt.sub_component('format',
                                              Table.format.fget,
                                              asrt.IsInstance(TableFormat))
        is_table_row = asrt.every_element('table row cells',
                                          is_table_cell)
        rows_assertion = asrt.sub_component_sequence('rows', Table.rows.fget, is_table_row, '/')

        assertion = asrt.And([format_assertion,
                              rows_assertion])

        assertion.apply(self.put, table, self.message_builder)
class _MatchesNode(AssertionBase[Node]):
    _HEADER_IS_STR = asrt.sub_component('header', Node.header.fget,
                                        asrt.is_instance(str))
    _IS_SEQUENCE_OF_DETAIL = asrt.every_element('details', is_any_detail())

    def __init__(
            self,
            header: Assertion[str] = asrt.anything_goes(),
            data: Assertion = asrt.anything_goes(),
            details: Assertion[Sequence[Detail]] = asrt.anything_goes(),
            children: Assertion[Sequence[Node]] = asrt.anything_goes(),
    ):
        self._header = header
        self._data = data
        self._details = details
        self._children = children

    def _apply(self, put: unittest.TestCase, value: Node,
               message_builder: MessageBuilder):
        self._assert_object_types(put, value, message_builder)

        self._header.apply(put, value.header,
                           message_builder.for_sub_component('header'))

        self._data.apply(put, value.data,
                         message_builder.for_sub_component('data'))

        self._details.apply(put, value.details,
                            message_builder.for_sub_component('details'))

        self._children.apply(put, value.children,
                             message_builder.for_sub_component('children'))

    def _assert_object_types(self, put: unittest.TestCase, value: Node,
                             message_builder: MessageBuilder):
        put.assertIsInstance(value, Node,
                             message_builder.apply('Node object type'))
        self._HEADER_IS_STR.apply(put, value, message_builder)
        self._IS_SEQUENCE_OF_DETAIL.apply(put, value.details, message_builder)
        asrt.every_element('children',
                           matches_node()).apply(put, value.children,
                                                 message_builder)
Ejemplo n.º 4
0
 def runTest(self):
     actual = self.documentation.syntax_element_descriptions()
     asrt.every_element('', is_syntax_element_description).apply(self, actual)
Ejemplo n.º 5
0
 def runTest(self):
     actual = self.documentation.invokation_variants()
     asrt.every_element('', is_invokation_variant).apply(self, actual)
Ejemplo n.º 6
0
 def runTest(self):
     actual = self.documentation.invokation_variants()
     asrt.every_element('invokation_variants',
                        is_invokation_variant).apply_without_message(
                            self, actual)
Ejemplo n.º 7
0
 def runTest(self):
     actual = self.documentation.syntax_element_descriptions()
     asrt.every_element('',
                        is_syntax_element_description).apply(self, actual)
Ejemplo n.º 8
0
 def runTest(self):
     actual = self.documentation.invokation_variants()
     asrt.every_element('', is_invokation_variant).apply(self, actual)
Ejemplo n.º 9
0
def is_paragraph_item_list(name: str = '') -> Assertion:
    return asrt.every_element(name, is_paragraph_item)
Ejemplo n.º 10
0
def is_cross_reference_target_list(name: str = '') -> Assertion:
    return asrt.every_element(name, is_cross_reference_target)
Ejemplo n.º 11
0
from exactly_lib.util.textformat.structure import core, lists, document as doc
from exactly_lib.util.textformat.structure.lists import HeaderContentList
from exactly_lib.util.textformat.structure.literal_layout import LiteralLayout
from exactly_lib.util.textformat.structure.paragraph import Paragraph
from exactly_lib.util.textformat.structure.table import Table, TableFormat, TableCell
from exactly_lib.util.textformat.structure.utils import ParagraphItemVisitor
from exactly_lib_test.test_resources.value_assertions import value_assertion as asrt
from exactly_lib_test.test_resources.value_assertions.value_assertion import Assertion, AssertionBase


def is_paragraph_item_list(name: str = '') -> Assertion:
    return asrt.every_element(name, is_paragraph_item)


is_tags_set = asrt.is_instance_with(set,
                                    asrt.every_element('set of tags', asrt.is_instance(str)))

is_string_text = asrt.is_instance_with(core.StringText,
                                       asrt.and_([
                                           asrt.sub_component('value',
                                                              core.StringText.value.fget,
                                                              asrt.IsInstance(str)),

                                           asrt.sub_component('tags',
                                                              core.StringText.tags.fget,
                                                              is_tags_set),
                                       ]))

is_cross_reference_text = asrt.is_instance_with(core.CrossReferenceText,
                                                asrt.And([
                                                    asrt.sub_component('target',
Ejemplo n.º 12
0
                                self).apply(put, value, message_builder)


_is_TargetInfoNodeObject_shallow = asrt.And([
    asrt.IsInstance(TargetInfoNode),
    asrt.sub_component('data',
                       TargetInfoNode.data.fget,
                       is_target_info),
    asrt.sub_component('children',
                       TargetInfoNode.children.fget,
                       asrt.IsInstance(list)),
])

is_target_info_node = _IsTargetInfoNode()

is_target_info_node_list = asrt.every_element('nodes', is_target_info_node, '')


def _equals_target_info_node__shallow(expected: TargetInfoNode,
                                      mk_equals_cross_ref_id) -> ValueAssertion:
    return asrt.And([
        _is_TargetInfoNodeObject_shallow,
        asrt.sub_component('target_info',
                           TargetInfoNode.data.fget,
                           equals_target_info(expected.data,
                                              mk_equals_cross_ref_id)),
        asrt.sub_component('children',
                           TargetInfoNode.children.fget,
                           asrt.len_equals(len(expected.children), 'Number of children'))
    ])
Ejemplo n.º 13
0
               message_builder: asrt.MessageBuilder):
        _is_TargetInfoNodeObject_shallow.apply(put, value, message_builder)
        asrt.sub_component_sequence('children', TargetInfoNode.children.fget,
                                    self).apply(put, value, message_builder)


_is_TargetInfoNodeObject_shallow = asrt.And([
    asrt.IsInstance(TargetInfoNode),
    asrt.sub_component('data', TargetInfoNode.data.fget, is_target_info),
    asrt.sub_component('children', TargetInfoNode.children.fget,
                       asrt.IsInstance(list)),
])

is_target_info_node = _IsTargetInfoNode()

is_target_info_node_list = asrt.every_element('nodes', is_target_info_node, '')


def _equals_target_info_node__shallow(expected: TargetInfoNode,
                                      mk_equals_cross_ref_id) -> Assertion:
    return asrt.And([
        _is_TargetInfoNodeObject_shallow,
        asrt.sub_component(
            'target_info', TargetInfoNode.data.fget,
            equals_target_info(expected.data, mk_equals_cross_ref_id)),
        asrt.sub_component(
            'children', TargetInfoNode.children.fget,
            asrt.len_equals(len(expected.children), 'Number of children'))
    ])

Ejemplo n.º 14
0
 def setUp(self):
     self.put = test_case_with_failure_exception_set_to_test_exception()
     self.every_element_is_none = sut.every_element('iterable name',
                                                    sut.ValueIsNone())
Ejemplo n.º 15
0
 def setUp(self):
     self.put = test_case_with_failure_exception_set_to_test_exception()
     self.every_element_is_none = sut.every_element('iterable name',
                                                    sut.ValueIsNone())