Example #1
0
def test_validate_id():
    oid = ObjectIdType()

    oid.validate(FAKE_OID)
    oid.validate(str(FAKE_OID))

    with pytest.raises(ConversionError):
        oid.validate('foo')
Example #2
0
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")
Example #3
0
def test_objectidtype_on_invalid_objectid():
    obj = ObjectIdType()
    with pytest.raises(TypeError):
        obj.validate("123")