Skip to content

Instantly share code, notes, and snippets.

@koddr koddr/tests.py
Last active Jan 18, 2018

Embed
What would you like to do?
# Import Python packages
from datetime import datetime
# Import Django Test
from django.test import TestCase
# Import App models
from .models import Journal, Children
class JournalTestCase(TestCase):
def setUp(self):
children = Children.objects.create(name='Sara Doe', gender='F', birthday='2012-05-12', classroom=2)
Journal.objects.create(children=children, parent='John Doe', time_start=datetime.now())
def test_journal_add_new_record(self):
"""Test create a new record in `Journal` model."""
journal = Journal.objects.get(parent='John Doe')
self.assertEqual(journal.parent, 'John Doe')
def test_journal_edit_record(self):
"""Test edit a record in `Journal` model."""
journal = Children.objects.get(name='Sara Doe')
journal.time_end = datetime.now()
journal.save()
self.assertNotEqual(journal.time_end, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.