Пример #1
0
    def test_url(self):
        a = ObjectId("123456789012")
        self.assertEqual(a.url_encode(), "313233343536373839303132")
        self.assertEqual(a, ObjectId.url_decode("313233343536373839303132"))

        b = ObjectId()
        encoded = b.url_encode()
        self.assertEqual(b, ObjectId.url_decode(encoded))
Пример #2
0
    def test_legacy_string(self):
        a = ObjectId()

        self.assertEqual(a.url_encode(legacy=True), a.legacy_str().encode("hex"))

        self.assertNotEqual(str(a), a.legacy_str())
        self.assertEqual(a, ObjectId.from_legacy_str(a.legacy_str()))
Пример #3
0
 def test_url_legacy(self):
     a = ObjectId()
     self.assertNotEqual(a.url_encode(), a.url_encode(legacy=True))
     self.assertEqual(a, ObjectId.url_decode(a.url_encode(legacy=True), legacy=True))