def test_validate_id(): oid = ObjectIdType() oid.validate(FAKE_OID) oid.validate(str(FAKE_OID)) with pytest.raises(ConversionError): oid.validate('foo')
def test_objectidtype_on_objectd(): obj = ObjectIdType() try: obj.validate(bson.ObjectId("507f1f77bcf86cd799439011")) except pytest.raises(TypeError): pytest.fail("This exception shouldn't be raised")
def test_objectidtype_on_invalid_objectid(): obj = ObjectIdType() with pytest.raises(TypeError): obj.validate("123")