Skip to content

Commit

Permalink
Rename SQL Alchemy Database Adaper.
Browse files Browse the repository at this point in the history
This changes the class name from SQLAlchemyDatabaseAdapter
to SQLStorageAdapter. This change is becase we abstract the inner
workings of the SQL adapter and the user never really needs to
know what library is being used internally.
  • Loading branch information
gunthercox committed Jun 10, 2017
1 parent 54673b2 commit 424e4a6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions chatterbot/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from .django_storage import DjangoStorageAdapter
from .jsonfile import JsonFileStorageAdapter
from .mongodb import MongoDatabaseAdapter
from .sqlalchemy_storage import SQLAlchemyDatabaseAdapter
from .sql_storage import SQLStorageAdapter


__all__ = (
'StorageAdapter',
'DjangoStorageAdapter',
'JsonFileStorageAdapter',
'MongoDatabaseAdapter',
'SQLAlchemyDatabaseAdapter',
'SQLStorageAdapter',
)
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def get_response_table(response):
return ResponseTable(text=response.text, occurrence=response.occurrence)


class SQLAlchemyDatabaseAdapter(StorageAdapter):
class SQLStorageAdapter(StorageAdapter):

def __init__(self, **kwargs):
super(SQLAlchemyDatabaseAdapter, self).__init__(**kwargs)
super(SQLStorageAdapter, self).__init__(**kwargs)

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
Expand Down
2 changes: 1 addition & 1 deletion tests/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ def setUp(self):
def get_kwargs(self):
kwargs = super(ChatBotSQLTestCase, self).get_kwargs()
del kwargs['database']
kwargs['storage_adapter'] = 'chatterbot.storage.SQLAlchemyDatabaseAdapter'
kwargs['storage_adapter'] = 'chatterbot.storage.SQLStorageAdapter'
return kwargs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from tests.base_case import ChatBotSQLTestCase


class SqlAlchemyStorageIntegrationTests(ChatBotSQLTestCase):
class SqlStorageIntegrationTests(ChatBotSQLTestCase):

def test_database_is_updated(self):
"""
Expand Down
10 changes: 5 additions & 5 deletions tests/storage_adapter_tests/test_sqlalchemy_adapter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase
from chatterbot.conversation import Statement, Response
from chatterbot.storage.sqlalchemy_storage import SQLAlchemyDatabaseAdapter
from chatterbot.storage.sql_storage import SQLStorageAdapter


class SQLAlchemyAdapterTestCase(TestCase):
Expand All @@ -10,7 +10,7 @@ def setUpClass(cls):
"""
Instantiate the adapter before any tests in the test case run.
"""
cls.adapter = SQLAlchemyDatabaseAdapter()
cls.adapter = SQLStorageAdapter()

def setUp(self):
"""
Expand All @@ -25,7 +25,7 @@ def tearDown(self):
self.adapter.drop()


class SQLAlchemyDatabaseAdapterTestCase(SQLAlchemyAdapterTestCase):
class SQLStorageAdapterTestCase(SQLAlchemyAdapterTestCase):

def test_count_returns_zero(self):
"""
Expand Down Expand Up @@ -340,13 +340,13 @@ def test_response_list_in_results(self):
self.assertIsInstance(found[0].in_response_to[0], Response)


class ReadOnlySQLAlchemyDatabaseAdapterTestCase(SQLAlchemyAdapterTestCase):
class ReadOnlySQLStorageAdapterTestCase(SQLAlchemyAdapterTestCase):

def setUp(self):
"""
Make the adapter writable before every test.
"""
super(ReadOnlySQLAlchemyDatabaseAdapterTestCase, self).setUp()
super(ReadOnlySQLStorageAdapterTestCase, self).setUp()
self.adapter.read_only = False

def test_update_does_not_add_new_statement(self):
Expand Down

0 comments on commit 424e4a6

Please sign in to comment.