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
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
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
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']
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
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
def test_find_one_matching_is_true(sut: SqlalchemyRepository, widgets): assert sut.find_one_matching(Attr('deleted').is_true()) is widgets['baz']
def test_find_one_matching_is_none(sut: SqlalchemyRepository, widgets): assert sut.find_one_matching(Attr('priority').is_none()) is widgets['baz']
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
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
def test_find_one_matching_equality(sut: SqlalchemyRepository, widgets): assert sut.find_one_matching(Attr('name') == 'foo') is widgets['foo']
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']