def test_additionalProperties_true(user_spec, user, user_kwargs):
    # verify exra kwargs are attached to the model as attributes when
    # additionalProperties is True
    user_spec['additionalProperties'] = True
    user_kwargs['foo'] = 'bar'  # additional prop
    model_constructor(user, user_spec, user_kwargs)
    assert user.foo == 'bar'
    assert 'foo' in dir(user)
def test_empty_kwargs(user_spec, user):
    model_constructor(user, user_spec, {})
    assert user.firstName is None
    assert user.userStatus is None
    assert user.id is None
    assert user.lastName is None
    assert user.email is None
    assert user.password is None
def test_additionalProperties_defaults_to_true_when_not_present(
        user_spec, user, user_kwargs):
    # verify exra kwargs are attached to the model as attributes when
    # additionalProperties is not present
    user_kwargs['foo'] = 'bar'
    model_constructor(user, user_spec, user_kwargs)
    assert user.foo == 'bar'
    assert 'foo' in dir(user)
Пример #4
0
def test_additionalProperties_true(user_spec, user, user_kwargs):
    # verify exra kwargs are attached to the model as attributes when
    # additionalProperties is True
    user_spec['additionalProperties'] = True
    user_kwargs['foo'] = 'bar'  # additional prop
    model_constructor(user, user_spec, user_kwargs)
    assert user.foo == 'bar'
    assert 'foo' in dir(user)
def test_simple(user_spec, user, user_kwargs):
    model_constructor(user, user_spec, user_kwargs)
    assert user.firstName == 'Darwin'
    assert user.userStatus == 9
    assert user.id == 999L
    assert user.lastName is None
    assert user.email is None
    assert user.password is None
Пример #6
0
def test_additionalProperties_defaults_to_true_when_not_present(
        user_spec, user, user_kwargs):
    # verify exra kwargs are attached to the model as attributes when
    # additionalProperties is not present
    user_kwargs['foo'] = 'bar'
    model_constructor(user, user_spec, user_kwargs)
    assert user.foo == 'bar'
    assert 'foo' in dir(user)
Пример #7
0
def test_empty_kwargs(user_spec, user):
    model_constructor(user, user_spec, {})
    assert user.firstName is None
    assert user.userStatus is None
    assert user.id is None
    assert user.lastName is None
    assert user.email is None
    assert user.password is None
Пример #8
0
def test_simple(user_spec, user, user_kwargs):
    model_constructor(user, user_spec, user_kwargs)
    assert user.firstName == 'Darwin'
    assert user.userStatus == 9
    assert user.id == 999
    assert user.lastName is None
    assert user.email is None
    assert user.password is None
Пример #9
0
def test_allOf(cat, cat_spec, cat_swagger_spec, cat_kwargs):
    model_constructor(cat, cat_spec, cat_swagger_spec, cat_kwargs)
    assert cat.id == 12
    assert cat.category == {'id': 42, 'name': 'Feline'}
    assert cat.name == 'Oskar'
    assert cat.photoUrls == ['example.com/img1', 'example.com/img2']
    assert cat.tags == [{'id': 1, 'name': 'cute'}]
    assert cat.neutered is True
Пример #10
0
def test_additionalProperties_false(user_spec, user, user_kwargs):
    # verify exra kwargs are caught during model construction when
    # additionalProperties is False
    user_spec['additionalProperties'] = False
    user_kwargs['foo'] = 'bar'  # additional prop
    with pytest.raises(AttributeError) as excinfo:
        model_constructor(user, user_spec, user_kwargs)
    assert "does not have attributes for: ['foo']" in str(excinfo.value)
    assert not hasattr(user, 'foo')
    assert 'foo' not in dir(user)
Пример #11
0
def test_additionalProperties_false(user_spec, user, user_kwargs):
    # verify exra kwargs are caught during model construction when
    # additionalProperties is False
    user_spec['additionalProperties'] = False
    user_kwargs['foo'] = 'bar'  # additional prop
    with pytest.raises(AttributeError) as excinfo:
        model_constructor(user, user_spec, user_kwargs)
    assert "does not have attributes for: ['foo']" in str(excinfo.value)
    assert not hasattr(user, 'foo')
    assert 'foo' not in dir(user)