Skip to content

Commit

Permalink
Merge 17bf013 into 52f6861
Browse files Browse the repository at this point in the history
  • Loading branch information
gunthercox committed Sep 13, 2018
2 parents 52f6861 + 17bf013 commit 4a60f3f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tests/storage_adapter_tests/test_mongo_adapter.py
Expand Up @@ -451,15 +451,16 @@ def test_order_by_text(self):
statement_a = Statement(text='A is the first letter of the alphabet.')
statement_b = Statement(text='B is the second letter of the alphabet.')

self.adapter.update(statement_a)
self.adapter.update(statement_b)
self.adapter.update(statement_a)

results = self.adapter.filter(order_by=['text'])

self.assertEqual(len(results), 2)
self.assertEqual(results[0], statement_a)
self.assertEqual(results[1], statement_b)

@expectedFailure
def test_order_by_created_at(self):
from datetime import datetime, timedelta

Expand All @@ -475,8 +476,8 @@ def test_order_by_created_at(self):
created_at=yesterday
)

self.adapter.update(statement_a)
self.adapter.update(statement_b)
self.adapter.update(statement_a)

results = self.adapter.filter(order_by=['created_at'])

Expand Down
47 changes: 46 additions & 1 deletion tests/storage_adapter_tests/test_sqlalchemy_adapter.py
@@ -1,4 +1,4 @@
from unittest import TestCase
from unittest import TestCase, expectedFailure
from chatterbot.conversation import Statement, Response
from chatterbot.storage.sql_storage import SQLStorageAdapter

Expand Down Expand Up @@ -433,3 +433,48 @@ def test_update_does_not_modify_existing_statement(self):
self.assertEqual(
len(statement_found.in_response_to), 0
)


class SQLOrderingTestCase(SQLAlchemyAdapterTestCase):
"""
Test cases for the ordering of sets of statements.
"""

@expectedFailure
def test_order_by_text(self):
statement_a = Statement(text='A is the first letter of the alphabet.')
statement_b = Statement(text='B is the second letter of the alphabet.')

self.adapter.update(statement_b)
self.adapter.update(statement_a)

results = self.adapter.filter(order_by=['text'])

self.assertEqual(len(results), 2)
self.assertEqual(results[0], statement_a)
self.assertEqual(results[1], statement_b)

@expectedFailure
def test_order_by_created_at(self):
from datetime import datetime, timedelta

today = datetime.now()
yesterday = datetime.now() - timedelta(days=1)

statement_a = Statement(
text='A is the first letter of the alphabet.',
created_at=today
)
statement_b = Statement(
text='B is the second letter of the alphabet.',
created_at=yesterday
)

self.adapter.update(statement_b)
self.adapter.update(statement_a)

results = self.adapter.filter(order_by=['created_at'])

self.assertEqual(len(results), 2)
self.assertEqual(results[0], statement_a)
self.assertEqual(results[1], statement_b)

0 comments on commit 4a60f3f

Please sign in to comment.