Skip to content

Commit

Permalink
Add "both breasts" option for Feeding method (#52).
Browse files Browse the repository at this point in the history
  • Loading branch information
cdubz committed May 2, 2019
1 parent a80662c commit 0261f39
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
18 changes: 18 additions & 0 deletions core/migrations/0006_auto_20190502_1701.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
1 change: 1 addition & 0 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
14 changes: 13 additions & 1 deletion core/tests/tests_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_diaperchange_attributes(self):
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(
Expand All @@ -71,6 +71,18 @@ def test_feeding_create(self):
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):
Expand Down

0 comments on commit 0261f39

Please sign in to comment.