Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially fix SQL adapter tests #712

Merged
merged 2 commits into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chatterbot/storage/sqlalchemy_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ResponseTable(_base):

def get_reponse_serialized(context):
params = context.current_parameters
del (params['text_search'])
del params['text_search']
return json.dumps(params)

id = Column(Integer)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ jsondatabase>=0.1.7,<1.0.0
nltk>=3.2.0,<4.0.0
pymongo>=3.3.0,<4.0.0
python-twitter>=3.0.0,<4.0.0
SQLAlchemy==1.1.7
SQLAlchemy>=1.1,<1.2
19 changes: 11 additions & 8 deletions tests/storage_adapter_tests/test_sqlalchemy_adapter.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
from unittest import TestCase

from chatterbot.conversation import Statement, Response
from chatterbot.storage.sqlalchemy_storage import SQLAlchemyDatabaseAdapter


class SQLAlchemyAdapterTestCase(TestCase):

def setUp(self):
"""
Instantiate the adapter.
Instantiate the adapter before any tests in the test case run.
"""
from random import randint

# Generate a random name for the database
database_name = str(randint(0, 9000))

self.adapter = SQLAlchemyDatabaseAdapter(
database='sqlite_' + database_name,
database='testdb',
drop_create=True
)

def tearDown(self):
"""
Remove the test database.
"""
self.adapter.drop()


class SQLAlchemyDatabaseAdapterTestCase(SQLAlchemyAdapterTestCase):

def test_count_returns_zero(self):
"""
The count method should return a value of 0
Expand Down Expand Up @@ -334,6 +336,7 @@ def test_response_list_in_results(self):


class ReadOnlySQLAlchemyDatabaseAdapterTestCase(SQLAlchemyAdapterTestCase):

def test_update_does_not_add_new_statement(self):
self.adapter.read_only = True

Expand Down