示例#1
0
 def test_get_path_without_label(self):
     path = get_path(Element('Test'))
     self.assertEqual(path, ('Element', ))
示例#2
0
 def test_get_path_with_custom_group(self):
     path = get_path(Element('Test', group='Custom Group'))
     self.assertEqual(path, ('Custom_Group', ))
 def setUp(self):
     self.el1 = Element('data1')
     self.el2 = Element('data2')
     self.el3 = Element('data3')
     self.el4 = Element('data5', group='ValB')
     self.el5 = Element('data6', label='LabelA')
示例#4
0
 def setUp(self):
     self.element1 = Element(None, group='Value', label='Label')
     self.element2 = Element(None, group='Value', label='')
 def test_overlay_with_holomap(self):
     overlay = Overlay([('Custom', self.el6)])
     composite = overlay * HoloMap({0: Element(None, group='HoloMap')})
     self.assertEqual(composite.last.keys(), [('Custom', 'LabelA'),
                                              ('HoloMap', 'I')])
class CompositeComparisonTestCase(ComparisonTestCase):

    def setUp(self):
        self.el1 = Element('data1')
        self.el2 = Element('data2')
        self.el3 = Element('data3')
        self.el4 = Element('data5', group='ValB')
        self.el5 = Element('data6', label='LabelA')

    #========================#
    # Tests for layout trees #
    #========================#

    def test_layouttree_comparison_equal(self):
        t1 = self.el1 + self.el2
        t2 = self.el1 + self.el2
        self.assertEqual(t1, t2)

    def test_layouttree_comparison_equal_large(self):
        t1 = self.el1 + self.el2 + self.el4 + self.el5
        t2 = self.el1 + self.el2 + self.el4 + self.el5
        self.assertEqual(t1, t2)


    def test_layouttree_comparison_unequal_data(self):
        t1 = self.el1 + self.el2
        t2 = self.el1 + self.el3
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e),"'data2' != 'data3'")

    def test_layouttree_comparison_unequal_paths(self):
        t1 = self.el1 + self.el2
        t2 = self.el1 + self.el2.relabel(group='ValA')
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Layouts have mismatched paths.')

    def test_layouttree_comparison_unequal_sizes(self):
        t1 = self.el1 + self.el2
        t2 = self.el1 + self.el2 + self.el3
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Layouts have mismatched path counts.')

    #=============================#
    # Matching tests for Overlays #
    #=============================#

    def test_overlay_comparison_equal(self):
        t1 = self.el1 * self.el2
        t2 = self.el1 * self.el2
        self.assertEqual(t1, t2)

    def test_overlay_comparison_equal_large(self):
        t1 = self.el1 * self.el2 * self.el3 * self.el4
        t2 = self.el1 * self.el2 * self.el3 * self.el4
        self.assertEqual(t1, t2)


    def test_overlay_comparison_unequal_data(self):
        t1 = self.el1 * self.el2
        t2 = self.el1 * self.el3
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e),"'data2' != 'data3'")

    def test_overlay_comparison_unequal_paths(self):
        t1 = self.el1 * self.el2
        t2 = self.el1 * self.el2.relabel(group='ValA')
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Overlays have mismatched paths.')

    def test_overlay_comparison_unequal_sizes(self):
        t1 = self.el1 * self.el2
        t2 = self.el1 * self.el2 * self.el3
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Overlays have mismatched path counts.')


    #==================================#
    # Mixed composite comparison tests #
    #==================================#

    def test_composite_comparison_equal(self):
        t1 = (self.el1 * self.el2) + (self.el1 * self.el2)
        t2 = (self.el1 * self.el2) + (self.el1 * self.el2)
        self.assertEqual(t1, t2)

    def test_composite_unequal_data(self):
        t1 = (self.el1 * self.el2) + (self.el1 * self.el2)
        t2 = (self.el1 * self.el2) + (self.el1 * self.el3)
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), "'data2' != 'data3'")

    def test_composite_unequal_paths_outer(self):
        t1 = (self.el1 * self.el2) + (self.el1 * self.el2).relabel(group='ValA')
        t2 = (self.el1 * self.el2) + (self.el1 * self.el3)
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Layouts have mismatched paths.')

    def test_composite_unequal_paths_inner(self):
        t1 = (self.el1 * self.el2) + (self.el1 * self.el2.relabel(group='ValA'))
        t2 = (self.el1 * self.el2) + (self.el1 * self.el3)
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Overlays have mismatched paths.')


    def test_composite_unequal_sizes(self):
        t1 = (self.el1 * self.el2) + (self.el1 * self.el2) + self.el3
        t2 = (self.el1 * self.el2) + (self.el1 * self.el2)
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Layouts have mismatched path counts.')
 def test_element_init(self):
     Element('data1')
 def test_layouttree_deduplicate(self):
     for i in range(2, 10):
         l = Layout([Element([], label='0') for _ in range(i)])
         self.assertEqual(len(l), i)
 def setUp(self):
     self.el1 = Element('data1')
     self.el2 = Element('data2')
     self.el3 = Element('data3')
     self.el4 = Element('data5', group='ValB')
     self.el5 = Element('data6', label='LabelA')
示例#10
0
class CompositeComparisonTestCase(ComparisonTestCase):
    def setUp(self):
        self.el1 = Element('data1')
        self.el2 = Element('data2')
        self.el3 = Element('data3')
        self.el4 = Element('data5', group='ValB')
        self.el5 = Element('data6', label='LabelA')

    #========================#
    # Tests for layout trees #
    #========================#

    def test_layouttree_comparison_equal(self):
        t1 = self.el1 + self.el2
        t2 = self.el1 + self.el2
        self.assertEqual(t1, t2)

    def test_layouttree_comparison_equal_large(self):
        t1 = self.el1 + self.el2 + self.el4 + self.el5
        t2 = self.el1 + self.el2 + self.el4 + self.el5
        self.assertEqual(t1, t2)

    def test_layouttree_comparison_unequal_data(self):
        t1 = self.el1 + self.el2
        t2 = self.el1 + self.el3
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), "'data2' != 'data3'")

    def test_layouttree_comparison_unequal_paths(self):
        t1 = self.el1 + self.el2
        t2 = self.el1 + self.el2.relabel(group='ValA')
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Layouts have mismatched paths.')

    def test_layouttree_comparison_unequal_sizes(self):
        t1 = self.el1 + self.el2
        t2 = self.el1 + self.el2 + self.el3
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Layouts have mismatched path counts.')

    #=============================#
    # Matching tests for Overlays #
    #=============================#

    def test_overlay_comparison_equal(self):
        t1 = self.el1 * self.el2
        t2 = self.el1 * self.el2
        self.assertEqual(t1, t2)

    def test_overlay_comparison_equal_large(self):
        t1 = self.el1 * self.el2 * self.el3 * self.el4
        t2 = self.el1 * self.el2 * self.el3 * self.el4
        self.assertEqual(t1, t2)

    def test_overlay_comparison_unequal_data(self):
        t1 = self.el1 * self.el2
        t2 = self.el1 * self.el3
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), "'data2' != 'data3'")

    def test_overlay_comparison_unequal_paths(self):
        t1 = self.el1 * self.el2
        t2 = self.el1 * self.el2.relabel(group='ValA')
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Overlays have mismatched paths.')

    def test_overlay_comparison_unequal_sizes(self):
        t1 = self.el1 * self.el2
        t2 = self.el1 * self.el2 * self.el3
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Overlays have mismatched path counts.')

    #==================================#
    # Mixed composite comparison tests #
    #==================================#

    def test_composite_comparison_equal(self):
        t1 = (self.el1 * self.el2) + (self.el1 * self.el2)
        t2 = (self.el1 * self.el2) + (self.el1 * self.el2)
        self.assertEqual(t1, t2)

    def test_composite_unequal_data(self):
        t1 = (self.el1 * self.el2) + (self.el1 * self.el2)
        t2 = (self.el1 * self.el2) + (self.el1 * self.el3)
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), "'data2' != 'data3'")

    def test_composite_unequal_paths_outer(self):
        t1 = (self.el1 * self.el2) + (self.el1 *
                                      self.el2).relabel(group='ValA')
        t2 = (self.el1 * self.el2) + (self.el1 * self.el3)
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Layouts have mismatched paths.')

    def test_composite_unequal_paths_inner(self):
        t1 = (self.el1 * self.el2) + (self.el1 *
                                      self.el2.relabel(group='ValA'))
        t2 = (self.el1 * self.el2) + (self.el1 * self.el3)
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Overlays have mismatched paths.')

    def test_composite_unequal_sizes(self):
        t1 = (self.el1 * self.el2) + (self.el1 * self.el2) + self.el3
        t2 = (self.el1 * self.el2) + (self.el1 * self.el2)
        try:
            self.assertEqual(t1, t2)
        except AssertionError as e:
            self.assertEqual(str(e), 'Layouts have mismatched path counts.')
示例#11
0
 def test_get_path_from_item_with_custom_group_and_matching_label(self):
     path = get_path((('Custom', 'Path'), Element('Test', label='Path')))
     self.assertEqual(path, ('Custom', 'Path'))
示例#12
0
 def test_get_path_from_item_with_custom_group(self):
     path = get_path((('Custom', ), Element('Test')))
     self.assertEqual(path, ('Custom', ))
示例#13
0
 def test_get_path_with_custom_group_and_label(self):
     path = get_path(Element('Test', group='Custom Group', label='A'))
     self.assertEqual(path, ('Custom_Group', 'A'))