-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cd50a0
commit 1d1094b
Showing
8 changed files
with
67 additions
and
19 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
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,3 +1,8 @@ | ||
{ | ||
"python.formatting.provider": "autopep8" | ||
"python.formatting.provider": "autopep8", | ||
"python.testing.pytestArgs": [ | ||
"chat" | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
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 |
---|---|---|
@@ -1,3 +1,32 @@ | ||
from django.test import TestCase | ||
from django.utils import timezone | ||
from django.urls import reverse | ||
import datetime | ||
|
||
# Create your tests here. | ||
from .models import Utterance | ||
|
||
|
||
class UtteranceModelTests(TestCase): | ||
def test_is_recent_with_future_time(self): | ||
""" | ||
is_recent() returns False for future utterances | ||
""" | ||
future = timezone.now() + datetime.timedelta(days=30) | ||
future_utterance = Utterance(time=future, utterance_text='test') | ||
self.assertIs(future_utterance.is_recent(), False) | ||
|
||
def test_is_recent_with_old_utterance(self): | ||
""" | ||
is_recent() returns False for utterances whose time is older than 1 day | ||
""" | ||
day_old = timezone.now() - datetime.timedelta(days=1, seconds=1) | ||
old_utterance = Utterance(time=day_old, utterance_text='test') | ||
self.assertIs(old_utterance.is_recent(), False) | ||
|
||
def test_is_recent_with_recent_utterance(self): | ||
""" | ||
is_recent() returns True for utterances whose time is within the last day | ||
""" | ||
recent = timezone.now() - datetime.timedelta(hours=23, minutes=59) | ||
recent_utterance = Utterance(time=recent, utterance_text='test') | ||
self.assertIs(recent_utterance.is_recent(), True) |
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
Binary file not shown.
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,3 @@ | ||
[pytest] | ||
DJANGO_SETTINGS_MODULE = Amy.settings | ||
python_files = tests.py test_*.py *_tests.py |