예제 #1
0
    def test_times_auto(self):

        meta = MetaData()

        before = time.time()

        meta.set_create_time(None)
        meta.set_send_time(None)
        meta.set_receive_time(None)
        meta.set_deliver_time(None)

        after = time.time()

        assert meta.create_time is not None
        assert meta.send_time is not None
        assert meta.receive_time is not None
        assert meta.deliver_time is not None

        assert before <= meta.create_time
        assert before <= meta.send_time
        assert before <= meta.receive_time
        assert before <= meta.deliver_time

        assert after >= meta.create_time
        assert after >= meta.send_time
        assert after >= meta.receive_time
        assert after >= meta.deliver_time
예제 #2
0
    def test_comparison(self):

        meta1 = MetaData()
        meta2 = MetaData()
        meta2.set_create_time(meta1.create_time)
        assert meta1 == meta2

        meta1.set_create_time(213123)
        assert meta1 != meta2
        meta2.set_create_time(meta1.create_time)
        assert meta1 == meta2

        meta1.set_send_time()
        assert meta1 != meta2
        meta2.set_send_time(meta1.send_time)
        assert meta1 == meta2

        meta1.set_receive_time()
        assert meta1 != meta2
        meta2.set_receive_time(meta1.receive_time)
        assert meta1 == meta2

        meta1.set_deliver_time()
        assert meta1 != meta2
        meta2.set_deliver_time(meta1.deliver_time)
        assert meta1 == meta2

        meta1.set_user_time("foo")
        assert meta1 != meta2
        meta2.set_user_time("foo", meta1.user_times["foo"])
        assert meta1 == meta2

        meta1.set_user_info("foox", "bla")
        assert meta1 != meta2
        meta2.set_user_info("foox", meta1.user_infos["foox"])
        assert meta1 == meta2