示例#1
0
    def get_duration(self):
        data = self.get_dict()
        start_name = _get_tag_or_element_type_xpath(self.xform, START)
        end_name = _get_tag_or_element_type_xpath(self.xform, END)
        start_time, end_time = data.get(start_name), data.get(end_name)

        return calculate_duration(start_time, end_time)
示例#2
0
文件: instance.py 项目: onaio/onadata
    def get_duration(self):
        data = self.get_dict()
        # pylint: disable=no-member
        start_name = _get_tag_or_element_type_xpath(self.xform, START)
        end_name = _get_tag_or_element_type_xpath(self.xform, END)
        start_time, end_time = data.get(start_name), data.get(end_name)

        return calculate_duration(start_time, end_time)
示例#3
0
    def get_duration(self):
        data = self.get_dict()
        dd = self.xform.data_dictionary()
        start_name = _get_tag_or_element_type_xpath(dd, START)
        end_name = _get_tag_or_element_type_xpath(dd, END)
        start_time, end_time = data.get(start_name), data.get(end_name)

        return calculate_duration(start_time, end_time)
示例#4
0
    def test_duration_field_on_metadata(self):
        # the instance below has valid start and end times
        instance = Instance.objects.all()[0]
        _dict = instance.parsed_instance.to_dict_for_mongo()
        self.assertIn('_duration', list(_dict))
        self.assertEqual(_dict.get('_duration'), 24.0)
        self.assertNotEqual(_dict.get('_duration'), None)

        _dict = instance.json
        duration = calculate_duration(_dict.get('start_time'), 'invalid')
        self.assertIn('_duration', list(_dict))
        self.assertEqual(duration, '')
        self.assertNotEqual(duration, None)
示例#5
0
    def test_duration_field_on_metadata(self):
        # the instance below has valid start and end times
        instance = Instance.objects.all()[0]
        _dict = instance.parsed_instance.to_dict_for_mongo()
        self.assertIn('_duration', _dict.keys())
        self.assertEqual(_dict.get('_duration'), 24.0)
        self.assertNotEqual(_dict.get('_duration'), None)

        _dict = instance.json
        duration = calculate_duration(_dict.get('start_time'), 'invalid')
        self.assertIn('_duration', _dict.keys())
        self.assertEqual(duration, '')
        self.assertNotEqual(duration, None)
示例#6
0
    def get_duration(self):
        data = self.instance.get_dict()
        _start, _end = data.get(START_TIME, ''), data.get(END_TIME, '')

        return calculate_duration(_start, _end)
示例#7
0
    def get_duration(self):
        data = self.instance.get_dict()
        _start, _end = data.get(START_TIME, ''), data.get(END_TIME, '')

        return calculate_duration(_start, _end)