Beispiel #1
0
    def test_can_merge_two_mergeable_collections(self):
        """Test if merge two mergeable time-slot collections.
        """
        # same interval but different channel
        col1 = TimeslotCollection(Timeslot(Interval(1, 3), AcquireChannel(0)))
        col2 = TimeslotCollection(Timeslot(Interval(1, 3), AcquireChannel(1)))
        self.assertEqual(True, col1.is_mergeable_with(col2))
        expected = TimeslotCollection(Timeslot(Interval(1, 3), AcquireChannel(0)),
                                      Timeslot(Interval(1, 3), AcquireChannel(1)))
        self.assertEqual(expected, col1.merged(col2))

        # same channel but different interval
        col1 = TimeslotCollection(Timeslot(Interval(1, 3), AcquireChannel(0)))
        col2 = TimeslotCollection(Timeslot(Interval(3, 5), AcquireChannel(0)))
        self.assertEqual(True, col1.is_mergeable_with(col2))
        expected = TimeslotCollection(Timeslot(Interval(1, 3), AcquireChannel(0)),
                                      Timeslot(Interval(3, 5), AcquireChannel(0)))
        self.assertEqual(expected, col1.merged(col2))
Beispiel #2
0
    def test_empty_collection(self):
        """Test empty collection creation and its operations.
        """
        empty = TimeslotCollection()
        self.assertEqual(True, empty.is_mergeable_with(empty))

        # can merge with normal collection
        normal = TimeslotCollection(Timeslot(Interval(1, 3), AcquireChannel(0)),
                                    Timeslot(Interval(3, 5), AcquireChannel(0)))
        self.assertEqual(True, empty.is_mergeable_with(normal))
        self.assertEqual(normal, empty.merged(normal))