コード例 #1
0
 def setUp(self):
     self.initial = SortableDict([
         ('b', 1),
         ('a', 2),
         ('c', 3),
     ])
     self.expected = SortableDict([
         ('a', 2),
         ('b', 1),
         ('c', 3),
     ])
コード例 #2
0
class FobiDataStructuresTest(TestCase):
    """
    Tests of django-fobi ``data_structures`` module functionality.
    """
    def setUp(self):
        self.initial = SortableDict(
            [
                ('b', 1),
                ('a', 2),
                ('c', 3),
            ]
            )
        self.expected = SortableDict(
            [
                ('a', 2),
                ('b', 1),
                ('c', 3),
            ]
            )

    @print_info
    def test_01_sortable_dict_move_before_key(self):
        """
        Test the ``fobi.data_structures.SortableDict.move_before_key`` method.
        """
        flow = []

        flow.append(copy(self.initial))

        # Expected: a, b, c
        res = self.initial.move_before_key(source_key='a', target_key='b')
        self.assertTrue(res)

        flow.append(copy(self.initial))
        self.assertTrue(self.initial == self.expected)

        return flow

    @print_info
    def test_02_sortable_dict_move_after_key(self):
        """
        Test the ``fobi.data_structures.SortableDict.move_after_key`` method.
        """
        flow = []

        flow.append(copy(self.initial))

        res = self.initial.move_after_key(source_key='b', target_key='a') # Expected: a, b, c
        self.assertTrue(res)

        flow.append(copy(self.initial))
        self.assertTrue(self.initial == self.expected)

        return flow
コード例 #3
0
class FobiDataStructuresTest(TestCase):
    """
    Tests of django-fobi ``data_structures`` module functionality.
    """
    def setUp(self):
        self.initial = SortableDict([
            ('b', 1),
            ('a', 2),
            ('c', 3),
        ])
        self.expected = SortableDict([
            ('a', 2),
            ('b', 1),
            ('c', 3),
        ])

    @print_info
    def test_01_sortable_dict_move_before_key(self):
        """
        Test the ``fobi.data_structures.SortableDict.move_before_key`` method.
        """
        flow = []

        flow.append(copy(self.initial))

        # Expected: a, b, c
        res = self.initial.move_before_key(source_key='a', target_key='b')
        self.assertTrue(res)

        flow.append(copy(self.initial))
        self.assertTrue(self.initial == self.expected)

        return flow

    @print_info
    def test_02_sortable_dict_move_after_key(self):
        """
        Test the ``fobi.data_structures.SortableDict.move_after_key`` method.
        """
        flow = []

        flow.append(copy(self.initial))

        res = self.initial.move_after_key(source_key='b',
                                          target_key='a')  # Expected: a, b, c
        self.assertTrue(res)

        flow.append(copy(self.initial))
        self.assertTrue(self.initial == self.expected)

        return flow
コード例 #4
0
 def setUp(self):
     self.initial = SortableDict(
         [
             ('b', 1),
             ('a', 2),
             ('c', 3),
         ]
         )
     self.expected = SortableDict(
         [
             ('a', 2),
             ('b', 1),
             ('c', 3),
         ]
         )