Add "both breasts" option for Feeding method (#52).

This commit is contained in:
Christopher C. Wells 2019-05-02 10:19:56 -07:00
parent a80662c4b1
commit 0261f39864
3 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2 on 2019-05-02 17:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0005_auto_20190416_2048'),
]
operations = [
migrations.AlterField(
model_name='feeding',
name='method',
field=models.CharField(choices=[('bottle', 'Bottle'), ('left breast', 'Left breast'), ('right breast', 'Right breast'), ('both breasts', 'Both breasts')], max_length=255, verbose_name='Method'),
),
]

View File

@ -203,6 +203,7 @@ class Feeding(models.Model):
('bottle', _('Bottle')),
('left breast', _('Left breast')),
('right breast', _('Right breast')),
('both breasts', _('Both breasts')),
],
max_length=255,
verbose_name=_('Method')

View File

@ -49,7 +49,7 @@ class DiaperChangeTestCase(TestCase):
self.change.attributes(), ['wet', 'solid', 'black'])
class FeedingChangeTestCase(TestCase):
class FeedingTestCase(TestCase):
def setUp(self):
call_command('migrate', verbosity=0)
self.child = models.Child.objects.create(
@ -71,6 +71,18 @@ class FeedingChangeTestCase(TestCase):
self.assertEqual(str(feeding), 'Feeding')
self.assertEqual(feeding.duration, feeding.end - feeding.start)
def test_method_both_breasts(self):
feeding = models.Feeding.objects.create(
child=self.child,
start=timezone.localtime() - timezone.timedelta(minutes=30),
end=timezone.localtime(),
type='breast milk',
method='both breasts'
)
self.assertEqual(feeding, models.Feeding.objects.first())
self.assertEqual(str(feeding), 'Feeding')
self.assertEqual(feeding.method, 'both breasts')
class NoteTestCase(TestCase):
def setUp(self):