def test_card_statistics(self):
        data = cards.card_statistics(self.child)
        stats = [{
            'title': 'Diaper change frequency',
            'stat': timezone.timedelta(0, 44228, 571429),
            'type': 'duration'
        }, {
            'title': 'Feeding frequency',
            'stat': timezone.timedelta(0, 7200),
            'type': 'duration'
        }, {
            'title': 'Average nap duration',
            'stat': timezone.timedelta(0, 4500),
            'type': 'duration'
        }, {
            'title': 'Average naps per day',
            'stat': 2.0,
            'type': 'float'
        }, {
            'title': 'Average sleep duration',
            'stat': timezone.timedelta(0, 6750),
            'type': 'duration'
        }, {
            'title': 'Average awake duration',
            'stat': timezone.timedelta(0, 19200),
            'type': 'duration'
        }, {
            'title': 'Weight change per week',
            'stat': 1.0,
            'type': 'float'
        }]

        self.assertEqual(data['stats'], stats)
示例#2
0
    def test_card_statistics(self):
        data = cards.card_statistics(self.context, self.child)
        stats = [
            {
                'title': 'Diaper change frequency',
                'stat': timezone.timedelta(0, 44228, 571429),
                'type': 'duration'
            },
            # Statistics date basis is not particularly strong to these feeding
            # examples.
            # TODO: Improve testing of feeding frequency statistics.
            {
                'type': 'duration',
                'stat': 0.0,
                'title': 'Feeding frequency (past 3 days)'
            },
            {
                'type': 'duration',
                'stat': 0.0,
                'title': 'Feeding frequency (past 2 weeks)'
            },
            {
                'type': 'duration',
                'stat': timezone.timedelta(0, 7200),
                'title': 'Feeding frequency'
            },
            {
                'title': 'Average nap duration',
                'stat': timezone.timedelta(0, 4500),
                'type': 'duration'
            },
            {
                'title': 'Average naps per day',
                'stat': 2.0,
                'type': 'float'
            },
            {
                'title': 'Average sleep duration',
                'stat': timezone.timedelta(0, 6750),
                'type': 'duration'
            },
            {
                'title': 'Average awake duration',
                'stat': timezone.timedelta(0, 19200),
                'type': 'duration'
            },
            {
                'title': 'Weight change per week',
                'stat': 1.0,
                'type': 'float'
            }
        ]

        self.assertEqual(data['stats'], stats)
        self.assertFalse(data['empty'])
        self.assertFalse(data['hide_empty'])
示例#3
0
    def test_card_statistics(self):
        data = cards.card_statistics(self.child)
        stats = [
            {
                'title': 'Diaper change frequency',
                'stat': timezone.timedelta(0, 44228, 571429),
                'type': 'duration'
            },
            {
                'title': 'Feeding frequency',
                'stat': timezone.timedelta(0, 7200),
                'type': 'duration'
            },
            {
                'title': 'Average nap duration',
                'stat': timezone.timedelta(0, 4500),
                'type': 'duration'
            },
            {
                'title': 'Average naps per day',
                'stat': 2.0,
                'type': 'float'
            },
            {
                'title': 'Average sleep duration',
                'stat': timezone.timedelta(0, 6750),
                'type': 'duration'
            },
            {
                'title': 'Average awake duration',
                'stat': timezone.timedelta(0, 19200),
                'type': 'duration'
            },
            {
                'title': 'Weight change per week',
                'stat': 1.0, 'type':
                'float'
            }
        ]

        # Python 2 comes up with a slightly different number for one record.
        if six.PY2:
            stats[0]['stat'] = timezone.timedelta(0, 44228, 571428)

        self.assertEqual(data['stats'], stats)
示例#4
0
    def test_card_statistics(self):
        data = cards.card_statistics(self.context, self.child)
        stats = [
            # Statistics date basis is not particularly strong to these diaper change
            # examples.
            # TODO: Improve testing of diaper change frequency statistics.
            {
                "type": "duration",
                "stat": 0.0,
                "title": "Diaper change frequency (past 3 days)",
            },
            {
                "type": "duration",
                "stat": 0.0,
                "title": "Diaper change frequency (past 2 weeks)",
            },
            {
                "title": "Diaper change frequency",
                "stat": timezone.timedelta(0, 44228, 571429),
                "type": "duration",
            },
            # Statistics date basis is not particularly strong to these feeding
            # examples.
            # TODO: Improve testing of feeding frequency statistics.
            {
                "type": "duration",
                "stat": 0.0,
                "title": "Feeding frequency (past 3 days)",
            },
            {
                "type": "duration",
                "stat": 0.0,
                "title": "Feeding frequency (past 2 weeks)",
            },
            {
                "type": "duration",
                "stat": timezone.timedelta(days=1, seconds=46980),
                "title": "Feeding frequency",
            },
            {
                "title": "Average nap duration",
                "stat": timezone.timedelta(0, 4500),
                "type": "duration",
            },
            {
                "title": "Average naps per day",
                "stat": 2.0,
                "type": "float"
            },
            {
                "title": "Average sleep duration",
                "stat": timezone.timedelta(0, 6750),
                "type": "duration",
            },
            {
                "title": "Average awake duration",
                "stat": timezone.timedelta(0, 19200),
                "type": "duration",
            },
            {
                "title": "Weight change per week",
                "stat": 1.0,
                "type": "float"
            },
            {
                "title": "Height change per week",
                "stat": 1.0,
                "type": "float"
            },
            {
                "title": "Head circumference change per week",
                "stat": 1.0,
                "type": "float",
            },
            {
                "title": "BMI change per week",
                "stat": 1.0,
                "type": "float"
            },
        ]

        self.assertEqual(data["stats"], stats)
        self.assertFalse(data["empty"])
        self.assertFalse(data["hide_empty"])