예제 #1
0
def test_m2m_save_blank():
    obj = Student(name='tim')
    validator = ModelValidator(obj)

    valid = validator.validate({'courses': [{}, {}]})
    assert valid

    validator.save()

    assert obj.id
예제 #2
0
def test_m2m_save_blank():
    obj = Student(name='tim')
    validator = ModelValidator(obj)

    valid = validator.validate({'courses': [{}, {}]})
    assert valid

    validator.save()

    assert obj.id
예제 #3
0
def test_save():
    obj = BasicFields(field1='one', field2='124124', field3='1232314')

    validator = ModelValidator(obj)
    valid = validator.validate({'field1': 'updated'})
    assert valid

    validator.save()

    assert obj.id
    assert obj.field1 == 'updated'
예제 #4
0
def test_save():
    obj = BasicFields(field1='one', field2='124124', field3='1232314')

    validator = ModelValidator(obj)
    valid = validator.validate({'field1': 'updated'})
    assert valid

    validator.save()

    assert obj.id
    assert obj.field1 == 'updated'
예제 #5
0
def test_m2m_save():
    obj = Student(name='tim')
    validator = ModelValidator(obj)

    c1 = Course.create(name='course1')
    c2 = Course.create(name='course2')

    valid = validator.validate({'courses': [c1, c2]})
    assert valid

    validator.save()

    assert obj.id
    assert c1 in obj.courses
    assert c2 in obj.courses
예제 #6
0
def test_m2m_save():
    obj = Student(name='tim')
    validator = ModelValidator(obj)

    c1 = Course.create(name='course1')
    c2 = Course.create(name='course2')

    valid = validator.validate({'courses': [c1, c2]})
    assert valid

    validator.save()

    assert obj.id
    assert c1 in obj.courses
    assert c2 in obj.courses