Skip to content

Commit

Permalink
bug fix for issue doableware#131
Browse files Browse the repository at this point in the history
  • Loading branch information
nesdis committed Aug 28, 2018
1 parent ebb6ae5 commit 0f093b9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/djongo_tests/project/project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
from django.contrib import admin

urlpatterns = [
# url(r'^admin/', admin.site.urls),
url(r'^admin/', admin.site.urls),
]
34 changes: 29 additions & 5 deletions tests/mock_tests/test_sqlparsing.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import typing
from collections import OrderedDict
from logging import getLogger, DEBUG, StreamHandler
from unittest import TestCase, mock, skip
from unittest.mock import patch, MagicMock

from logging import getLogger, DEBUG, StreamHandler
from pymongo.cursor import Cursor
from pymongo.command_cursor import CommandCursor
from pymongo.cursor import Cursor

from djongo.sql2mongo.query import Result
from djongo.base import DatabaseWrapper
from djongo.sql2mongo.query import Result

'Django SQL:'

Expand Down Expand Up @@ -661,7 +661,7 @@ def test_special(self):


# 'SELECT (1) AS "a" FROM "django_session" WHERE "django_session"."session_key" = %(0)s LIMIT 1'
self.sql = 'SELECT (1) AS "a" FROM "table1" WHERE "table1"."col2" = %s LIMIT 1'
self.sql = 'SELECT "auth_group"."id", "auth_group"."name" FROM "auth_group" WHERE (NOT ("auth_group"."name" = %(0)s) AND NOT ("auth_group"."name" = %(1)s))'
find_args = {
'filter': {
'col2': {
Expand All @@ -671,7 +671,7 @@ def test_special(self):
'limit': 1,
'projection': []
}
self.params = [1]
self.params = ['a', 'b']
ret = self.find_mock()
self.assertEqual(ret, [(1,)])
self.find.assert_any_call(**find_args)
Expand Down Expand Up @@ -1230,6 +1230,30 @@ def test_and_or(self):
find.assert_any_call(**find_args)
conn.reset_mock()

self.sql = f'{where} (NOT ({t1c1} <= %s) AND NOT ({t1c1} = %s))'
find_args['filter'] = {
'$and': [
{
'col1': {
'$not': {
'$lte': 2
}
}
},
{
'col1': {
'$not': {
'$eq': 1
}
}
}
]
}
self.params = [2, 1]
self.find_mock()
find.assert_any_call(**find_args)
conn.reset_mock()

self.sql = f'{where} NOT ({t1c1} <= %s AND {t1c1} = %s)'
find_args['filter'] = {
'$or': [
Expand Down

0 comments on commit 0f093b9

Please sign in to comment.