Skip to content

Commit

Permalink
fixing sqlalchemy empty() test case
Browse files Browse the repository at this point in the history
  • Loading branch information
miki725 committed Jul 26, 2018
1 parent 6bf1a7e commit 48ff031
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-r requirements.txt
alchemy-mock
coreapi
coverage
django-extensions
Expand Down
19 changes: 3 additions & 16 deletions tests/backends/test_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import pytest
import six
from alchemy_mock.comparison import ExpressionMatcher
from sqlalchemy import func
from sqlalchemy.sql.elements import ClauseList, Grouping
from sqlalchemy.types import String

from test_project.one_to_one.alchemy import Place, Restaurant, Waiter
Expand All @@ -13,20 +13,7 @@


def assert_alchemy_expressions_equal(exp1, exp2):
assert six.text_type(exp1) == six.text_type(exp2)

if isinstance(exp1.right, Grouping):
values1 = list(i.value for i in exp1.right.element.clauses)
values2 = list(i.value for i in exp2.right.element.clauses)
assert values1 == values2

elif isinstance(exp1.right, ClauseList):
values1 = list(i.value for i in exp1.right.clauses)
values2 = list(i.value for i in exp2.right.clauses)
assert values1 == values2

elif hasattr(exp1.right, 'value'):
assert exp1.right.value == exp2.right.value
assert ExpressionMatcher(exp1) == exp2


class TestSQLAlchemyFilterBackend(object):
Expand All @@ -50,7 +37,7 @@ def test_empty(self, alchemy_db):
context={'context': 'here'},
)

assert backend.empty().count() == 0
assert 'WHERE 0 = 1' in six.text_type(backend.empty())

def test_get_model(self, alchemy_db):
backend = SQLAlchemyFilterBackend(alchemy_db.query(Place))
Expand Down

0 comments on commit 48ff031

Please sign in to comment.