コード例 #1
0
ファイル: views.py プロジェクト: rajeevs1992/pyhealthvault
def mvaultentry(request):
    height_filter = ThingFilter()
    height_format = ThingFormat()
    height_format.sections.append('core')
    height_format.sections.append('xml')
    height_filter.typeids.append('40750a6a-89b2-455c-bd8d-b420a4cb500b')
    height_group = ThingGroup()
    height_group.filters = [height_filter]
    height_group.format = height_format
    height_group.max = 10

    basic_filter = ThingFilter()
    basic_format = ThingFormat()
    basic_format.sections.append('core')
    basic_filter.typeids.append('3b3e6b16-eb69-483c-8d7e-dfe116ae6092')
    basic_group = ThingGroup()
    basic_group.filters = [basic_filter]
    basic_group.format = basic_format


    method = GetThings([height_group, basic_group])
    method.execute(request.session['connection'])
    args = {}
    keys = []
    args['demographic'] = method.response.groups[1].healthrecorditems[0]
    args['heights'] = method.response.groups[0].healthrecorditems
    return render_to_response('hvdata.html', args)
コード例 #2
0
    def test_getthings_max(self):
        typeid = '40750a6a-89b2-455c-bd8d-b420a4cb500b'
        height_filter = ThingFilter()
        height_format = ThingFormat()
        height_format.sections.append('core')
        height_format.sections.append('xml')
        height_filter.typeids.append(typeid)

        group = ThingGroup()
        group.filters = [height_filter]
        group.format = height_format
        group.max = 5
        group.max_full = 3

        method = GetThings([group])
        method.execute(self.connection)

        self.assertEqual(len(method.response.groups), 1)

        if method.response.groups[0].healthrecorditems:
            items = method.response.groups[0].healthrecorditems
            self.assertEqual(typeid, items[0].type_id)
            self.assertTrue(len(items) <= 5)

            if len(items) > 3:
                self.assertIsNotNone(items[2].value_m)
                self.assertIsNone(items[3].value_m)
                self.assertTrue(items[3].is_partial)
コード例 #3
0
    def test_getthings_order_by(self):
        # Height does not support sorting, hence weight
        typeid = '3d34d87e-7fc1-4153-800f-f56592cb0d17'
        weight_filter = ThingFilter()
        weight_format = ThingFormat()
        weight_format.sections.append('core')
        weight_format.sections.append('xml')
        weight_filter.typeids.append(typeid)

        order_by = ThingOrderBySpecs(typeid, 'When')
        order_by.direction = 'Desc'

        group = ThingGroup()
        group.filters = [weight_filter]
        group.format = weight_format
        group.order_by = order_by

        method = GetThings([group])
        method.execute(self.connection)

        self.assertEqual(len(method.response.groups), 1)

        if method.response.groups[0].healthrecorditems:
            items = method.response.groups[0].healthrecorditems
            self.assertEqual(typeid, items[0].type_id)
            self.assertIsNotNone(items[0].value_kg)
            self.assertTrue(items[0].when > items[1].when)
コード例 #4
0
    def test_getthings_validations_and_intents(self):
        typeid = '40750a6a-89b2-455c-bd8d-b420a4cb500b'
        height_filter = ThingFilter()
        height_format = ThingFormat()
        height_format.sections.append('core')
        height_format.sections.append('xml')
        height_filter.typeids.append(typeid)

        group = ThingGroup()
        group.filters = [height_filter]

        method = GetThings([group])
        with self.assertRaises(HealthServiceException):
            method.execute(self.connection)

        group.format = height_format
        group.intents = ThingIntentsSpec(['view', 'pingu'])

        method = GetThings([group])
        with self.assertRaises(HealthServiceException):
            method.execute(self.connection)

        group.intents = ThingIntentsSpec(['view', 'download'])
        method = GetThings([group])
        method.execute(self.connection)

        self.assertEqual(len(method.response.groups), 1)

        if method.response.groups[0].healthrecorditems:
            items = method.response.groups[0].healthrecorditems
            self.assertEqual(typeid, items[0].type_id)
コード例 #5
0
    def test_getthings_coreonly(self):
        typeid = '40750a6a-89b2-455c-bd8d-b420a4cb500b'
        height_filter = ThingFilter()
        height_format = ThingFormat()
        height_format.sections.append('core')
        height_filter.typeids.append(typeid)
        group = ThingGroup()
        group.filters = [height_filter]
        group.format = height_format

        method = GetThings([group])
        method.execute(self.connection)

        self.assertEqual(len(method.response.groups), 1)

        if method.response.groups[0].healthrecorditems:
            item = method.response.groups[0].healthrecorditems[0]
            self.assertEqual(typeid, item.type_id)
            self.assertIsNone(item.value_m)