コード例 #1
0
    def test_get_set_timestamps(self):
        ti = TrackInterval()
        nt.assert_false(ti.start.is_valid())
        nt.assert_false(ti.stop.is_valid())

        ts1, ts2 = Timestamp(1234, 1), Timestamp(5678, 2)
        ti.start = ts1
        ti.stop = ts2
        nt.ok_(ti.start == ts1)
        nt.ok_(ti.stop == ts2)

        # Confirm its a copy, not a reference
        ts1.set_frame(3)
        nt.ok_(ti.start != ts1)

        ti.start.set_frame(3)
        nt.ok_(ti.start == ts1)

        # Getting and setting with other constructor
        ti = TrackInterval(21, Timestamp(1234, 1), Timestamp(5678, 2))
        nt.ok_(ti.start.is_valid())
        nt.ok_(ti.stop.is_valid())
        nt.ok_(ti.start == Timestamp(1234, 1))
        nt.ok_(ti.stop == Timestamp(5678, 2))

        ti.stop = Timestamp()
        nt.assert_false(ti.stop.is_valid())
        ti.stop.set_time_seconds(4321)
        nt.assert_equals(ti.stop.get_time_seconds(), 4321)

        ts1 = Timestamp(8765, 4)
        ti.start = ts1
        nt.ok_(ti.start == ts1)
コード例 #2
0
    def test_frame(self):
        t1 = Timestamp()
        t1.set_frame(1)
        nose.tools.assert_equal(t1.get_frame(), 1)

        t2 = Timestamp(1234000000, 1)
        nose.tools.assert_equal(t2.get_frame(), 1)
コード例 #3
0
    def test_valid(self):
        t1 = Timestamp()
        nose.tools.assert_false(t1.is_valid())
        nose.tools.assert_false(t1.has_valid_time())
        nose.tools.assert_false(t1.has_valid_frame())

        t1.set_time_seconds(1234)
        nose.tools.assert_false(t1.is_valid())
        t1.set_frame(1)
        nose.tools.assert_true(t1.is_valid())
        nose.tools.assert_true(t1.has_valid_time())
        nose.tools.assert_true(t1.has_valid_frame())

        t1.set_invalid()
        nose.tools.assert_false(t1.is_valid())
        nose.tools.assert_false(t1.has_valid_time())
        nose.tools.assert_false(t1.has_valid_frame())
コード例 #4
0
    def test_timestamp(self):
        m = Metadata()
        self.populate_metadata(m)
        metadatas = [Metadata(), m]
        for m in metadatas:
            nt.assert_false(m.timestamp.is_valid())

            t = Timestamp()

            t.set_time_seconds(1234)
            m.timestamp = t
            nt.assert_equals(m.timestamp.get_time_seconds(), 1234)
            nt.assert_false(m.timestamp.has_valid_frame())

            t.set_frame(1)
            m.timestamp = t
            nt.ok_(m.timestamp == t)