Source

Webware / MiddleKit / Tests / MKDefaultMinMax.mkmodel / TestSamples.py

def test(store):
    # We're testing to see if the defaults made it
    # into the database. We have a row with i == 42
    # and all other fields blank and s == '42' and
    # all other fields blank.
    # Our defaults for b, i, l, f, s are
    # 1, 2, 3, 4.0, '5'.

    foos = store.fetchObjectsOfClass('Foo')
    foo = [foo for foo in foos if foo.valueForKey('i') == 42][0]
    assert foo.valueForKey('b') == 1
    assert foo.valueForKey('l') == 3
    assert foo.valueForKey('f') == 4.0
    assert foo.valueForKey('s') == '5'

    foo = [foo for foo in foos if foo.valueForKey('s') == '42'][0]
    assert foo.valueForKey('i') == 2

    # Next we test if we were able to specify 'none'
    # for attributes that have defaults.
    # We marked these objects with 43.
    foo = [foo for foo in foos if foo.valueForKey('i') == 43][0]
    assert foo.valueForKey('b') is None
    assert foo.valueForKey('l') is None
    assert foo.valueForKey('f') is None
    assert foo.valueForKey('s') is None

    foo = [foo for foo in foos if foo.valueForKey('s') == '43'][0]
    assert foo.valueForKey('i') is None
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.