Beispiel #1
0
def test_find_all_matching_and_or_clauses(sut: SqlalchemyRepository, widgets):
    result = sut.find_all_matching((Attr('name').contains('foo*')) & (
        (Attr('priority') == 1) | (Attr('name') == 'foobar')))

    assert len(result) == 2
    assert widgets['foo'] in result
    assert widgets['foobar'] in result
Beispiel #2
0
def test_find_all_matching_or_clause(sut: SqlalchemyRepository, widgets):
    result = sut.find_all_matching((Attr('name') == 'foo')
                                   | (Attr('name') == 'baz'))

    assert len(result) == 2
    assert widgets['foo'] in result
    assert widgets['baz'] in result
Beispiel #3
0
def test_find_all_matching_lte(sut: SqlalchemyRepository, widgets):
    result = sut.find_all_matching(Attr('priority') <= 3)

    assert len(result) == 3
    assert widgets['foo'] in result
    assert widgets['bar'] in result
    assert widgets['foobar'] in result
Beispiel #4
0
def test_find_one_matching_and_clause(sut: SqlalchemyRepository, widgets):
    assert sut.find_one_matching((Attr('name').contains('foo*'))
                                 & (Attr('priority') > 1)) is widgets['foobar']
Beispiel #5
0
def test_find_all_matching_in(sut: SqlalchemyRepository, widgets):
    result = sut.find_all_matching(Attr('name').is_in(['foo', 'foobar']))

    assert len(result) == 2
    assert widgets['foo'] in result
    assert widgets['foobar'] in result
Beispiel #6
0
def test_find_all_matching_is_true(sut: SqlalchemyRepository, widgets):
    result = sut.find_all_matching(Attr('deleted').is_true())

    assert len(result) == 1
    assert widgets['baz'] in result
Beispiel #7
0
def test_find_one_matching_is_true(sut: SqlalchemyRepository, widgets):
    assert sut.find_one_matching(Attr('deleted').is_true()) is widgets['baz']
Beispiel #8
0
def test_find_one_matching_is_none(sut: SqlalchemyRepository, widgets):
    assert sut.find_one_matching(Attr('priority').is_none()) is widgets['baz']
Beispiel #9
0
def test_find_all_matching_contains(sut: SqlalchemyRepository, widgets):
    result = sut.find_all_matching(Attr('name').contains('foo*'))

    assert len(result) == 2
    assert widgets['foo'] in result
    assert widgets['foobar'] in result
Beispiel #10
0
def test_find_all_matching_not_equal(sut: SqlalchemyRepository, widgets):
    result = sut.find_all_matching(Attr('name') != 'foo')

    assert len(result) == 3
    assert widgets['foo'] not in result
Beispiel #11
0
def test_find_one_matching_equality(sut: SqlalchemyRepository, widgets):
    assert sut.find_one_matching(Attr('name') == 'foo') is widgets['foo']
Beispiel #12
0
def test_find_all_matching_equality(sut: SqlalchemyRepository, widgets):
    result = sut.find_all_matching(Attr('name') == 'foo')

    assert len(result) == 1
    assert result[0] is widgets['foo']