-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from gunthercox/clean
General code cleanup
- Loading branch information
Showing
14 changed files
with
164 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
build | ||
dist | ||
database.db | ||
settings.py | ||
*.pyc | ||
*.swp | ||
*.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
class AdapterNotImplementedError(NotImplementedError): | ||
|
||
def __init__(self, message="This method must be overridden in a subclass method."): | ||
self.message = message | ||
|
||
def __str__(self): | ||
return self.message | ||
|
||
|
||
class EmptyDatabaseException(Exception): | ||
|
||
def __init__(self, message="The database currently contains no entries. At least one entry is expected. Make sure that you have read_only set to False."): | ||
self.message = message | ||
|
||
def __str__(self): | ||
return self.message | ||
|
||
|
||
class EmptyDatasetException(Exception): | ||
|
||
def __init__(self, message="An empty collection of elements was received when at least one entry was expected."): | ||
self.message = message | ||
|
||
def __str__(self): | ||
return self.message | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from .base_case import ChatBotTestCase | ||
|
||
|
||
class ChatterBotStorageIntegrationTests(ChatBotTestCase): | ||
|
||
def test_database_is_updated(self): | ||
""" | ||
Test that the database is updated when read_only is set to false. | ||
""" | ||
input_text = "What is the airspeed velocity of an unladen swallow?" | ||
exists_before = self.chatbot.storage.find(input_text) | ||
|
||
response = self.chatbot.get_response(input_text) | ||
exists_after = self.chatbot.storage.find(input_text) | ||
|
||
self.assertFalse(exists_before) | ||
self.assertTrue(exists_after) | ||
|
||
def test_database_is_not_updated_when_read_only(self): | ||
""" | ||
Test that the database is not updated when read_only is set to true. | ||
""" | ||
self.chatbot.storage.read_only = True | ||
|
||
input_text = "Who are you? The proud lord said." | ||
exists_before = self.chatbot.storage.find(input_text) | ||
|
||
response = self.chatbot.get_response(input_text) | ||
exists_after = self.chatbot.storage.find(input_text) | ||
|
||
self.assertFalse(exists_before) | ||
self.assertFalse(exists_after) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.