Пример #1
0
    def test_missing_data(self):

        expected = (
            {'children': {
                'muac': {'total': 2, 'existing': 1},
                'birthdate': {'total': 2, 'existing': 2},
                'weight': {'total': 2, 'existing': 1},
                'height': {'total': 2, 'existing': 0}},
             'household_members': {
                'gender': {'total': 3, 'existing': 3},
                 'birthdate': {'total': 3, 'existing': 3}},
             'women': {
                'muac': {'total': 1, 'existing': 1},
                 'edema': {'total': 1, 'existing': 0},
                 'birthdate': {'total': 1, 'existing': 1},
                 'weight': {'total': 1, 'existing': 0},
                 'height': {'total': 1, 'existing': 1}
            }
            }
        )

        self.assertEqual(
            expected,
            HouseholdMember.missing_data(
                HouseholdMember.objects.by_teamlead(self.team_member))
        )
    def test_missing_data(self):

        expected = (
            {'children': {
                'muac': {'total': 2, 'existing': 1},
                'birthdate': {'total': 2, 'existing': 2},
                'weight': {'total': 2, 'existing': 1},
                'height': {'total': 2, 'existing': 0}},
             'household_members': {
                'gender': {'total': 3, 'existing': 3},
                 'birthdate': {'total': 3, 'existing': 3}},
             'women': {
                'muac': {'total': 1, 'existing': 1},
                 'edema': {'total': 1, 'existing': 0},
                 'birthdate': {'total': 1, 'existing': 1},
                 'weight': {'total': 1, 'existing': 0},
                 'height': {'total': 1, 'existing': 1}
            }
            }
        )

        self.assertEqual(
            expected,
            HouseholdMember.missing_data(
                HouseholdMember.objects.by_teamlead(self.team_member))
        )
    def test_requested_survey_fields(self):
        qsl = QuestionnaireSpecification(
            specification=EXAMPLE_QSL,
            active=True,
        )
        qsl.save()

        self.assertEqual([
            'muac', 'weight', 'birthdate', 'height', u'naughty',
            u'Naughty since', u'Naughty time in months', u'Presents Allowed',
            u'Weight of Presents', u'Height of Presents', u'Height type'
        ],
                         HouseholdMember.requested_survey_fields()['children'])

        self.assertEqual([
            'muac',
            'height',
            'weight',
            'birthdate',
            'edema',
            u'Christmas Tree?',
            u'Christmas Carols?',
            u'White christmas?',
            u'Weight of Presents (kg)',
            u'Height of Presents (cm)',
            u'Christmas Tree?',
            u'Christmas Carols?',
            u'White christmas?',
            u'Weight of Presents (kg)',
            u'Height of Presents (cm)',
        ],
                         HouseholdMember.requested_survey_fields()['women'])

        self.assertEqual(
            [
                'birthdate',
                'gender',
            ],
            HouseholdMember.requested_survey_fields()['household_members'])

        missing_data = HouseholdMember.missing_data(
            HouseholdMember.objects.by_teamlead(self.team_member))

        self.assertEqual(
            {
                'existing': 2,
                'total': 2
            },
            missing_data['children']['naughty'],
        )

        self.assertEqual(
            {
                'existing': 0,
                'total': 2
            },
            missing_data['children']['Naughty since'],
        )

        self.assertEqual(
            {
                'existing': 1,
                'total': 1
            },
            missing_data['women']['Christmas Tree?'],
        )
    def test_requested_survey_fields(self):
        qsl = QuestionnaireSpecification(
            specification=EXAMPLE_QSL,
            active=True,
        )
        qsl.save()

        self.assertEqual([
            'muac',
            'weight',
            'birthdate',
            'height',
            u'naughty',
            u'Naughty since',
            u'Naughty time in months',
            u'Presents Allowed',
            u'Weight of Presents',
            u'Height of Presents',
            u'Height type'
        ], HouseholdMember.requested_survey_fields()['children'])

        self.assertEqual([
            'muac',
            'height',
            'weight',
            'birthdate',
            'edema',
            u'Christmas Tree?',
            u'Christmas Carols?',
            u'White christmas?',
            u'Weight of Presents (kg)',
            u'Height of Presents (cm)',
            u'Christmas Tree?',
            u'Christmas Carols?',
            u'White christmas?',
            u'Weight of Presents (kg)',
            u'Height of Presents (cm)',
        ], HouseholdMember.requested_survey_fields()['women'])

        self.assertEqual([
            'birthdate',
            'gender',
        ], HouseholdMember.requested_survey_fields()['household_members'])

        missing_data = HouseholdMember.missing_data(
            HouseholdMember.objects.by_teamlead(self.team_member))

        self.assertEqual(
            {'existing': 2, 'total': 2},
            missing_data['children']['naughty'],
        )

        self.assertEqual(
            {'existing': 0, 'total': 2},
            missing_data['children']['Naughty since'],
        )

        self.assertEqual(
            {'existing': 1, 'total': 1},
            missing_data['women']['Christmas Tree?'],
        )