Пример #1
0
    def test_callcenter_fixture_commcare_user(self):
        user = CommCareUser(_id='123', username="******")
        indicator_set = MockIndicatorSet(name='test',
                                         indicators=OrderedDict([
                                             ('user_case1', {
                                                 'i1': 1,
                                                 'i2': 2
                                             }),
                                             ('user_case2', {
                                                 'i1': 0,
                                                 'i2': 3
                                             })
                                         ]))
        restore_user = type(
            'OTARestoreCommCareUserFake', (OTARestoreCommCareUser, ), {
                'project': Domain(name='test', default_timezone='UTC'),
                'get_call_center_indicators':
                lambda self, config: indicator_set,
            })('test', user)

        fixture, = call_fixture_generator(mock_indicators_fixture_generator,
                                          restore_user)
        check_xml_line_by_line(
            self, ElementTree.tostring(fixture),
            ElementTree.tostring(gen_fixture(restore_user, indicator_set)))
Пример #2
0
    def test_callcenter_fixture_format(self):
        user = CommCareUser(_id='123')
        indicator_set = MockIndicatorSet(name='test',
                                         indicators=OrderedDict([
                                             ('user_case1', {
                                                 'i1': 1,
                                                 'i2': 2
                                             }),
                                             ('user_case2', {
                                                 'i1': 0,
                                                 'i2': 3
                                             })
                                         ]))

        fixture = gen_fixture(user, indicator_set)
        check_xml_line_by_line(
            self, """
        <fixture date="2014-01-01T00:00:00" id="indicators:test" user_id="{userid}">
            <indicators>
                <case id="user_case1">
                    <i1>1</i1>
                    <i2>2</i2>
                </case>
                <case id="user_case2">
                    <i1>0</i1>
                    <i2>3</i2>
                </case>
            </indicators>
        </fixture>
        """.format(userid=user.user_id), ElementTree.tostring(fixture))
 def test_callcenter_no_group(self):
     fixture = gen_fixture(self.user, TestIndicatorSet('domain', 'user'))
     check_xml_line_by_line(self, """
     <fixture id="indicators:call_center" user_id="{userid}">
         <indicators>
             <casesUpdatedInLastWeek>3</casesUpdatedInLastWeek>
             <casesUpdatedInWeekPrior>4</casesUpdatedInWeekPrior>
             <averageDurationPerCase>7</averageDurationPerCase>
         </indicators>
     </fixture>
     """.format(userid=self.user.user_id), ElementTree.tostring(fixture))
Пример #4
0
    def test_callcenter_fixture_commcare_user(self):
        user = CommCareUser(_id='123', username="******")
        indicator_set = MockIndicatorSet(name='test', indicators=OrderedDict([
            ('user_case1', {'i1': 1, 'i2': 2}),
            ('user_case2', {'i1': 0, 'i2': 3})
        ]))
        restore_user = type('OTARestoreCommCareUserFake' if six.PY3 else b'OTARestoreCommCareUserFake', (OTARestoreCommCareUser,), {
            'project': Domain(name='test', default_timezone='UTC'),
            'get_call_center_indicators': lambda self, config: indicator_set,
        })('test', user)

        fixture, = call_fixture_generator(mock_indicators_fixture_generator, restore_user)
        check_xml_line_by_line(
            self, ElementTree.tostring(fixture),
            ElementTree.tostring(gen_fixture(restore_user, indicator_set)))
    def test_callcenter_fixture_format(self):
        user = CommCareUser(_id='123')
        indicator_set = MockIndicatorSet(name='test', indicators=OrderedDict([
            ('user_case1', {'i1': 1, 'i2': 2}),
            ('user_case2', {'i1': 0, 'i2': 3})
        ]))

        fixture = gen_fixture(user, indicator_set)
        check_xml_line_by_line(self, """
        <fixture date="2014-01-01T00:00:00" id="indicators:test" user_id="{userid}">
            <indicators>
                <case id="user_case1">
                    <i1>1</i1>
                    <i2>2</i2>
                </case>
                <case id="user_case2">
                    <i1>0</i1>
                    <i2>3</i2>
                </case>
            </indicators>
        </fixture>
        """.format(userid=user.user_id), ElementTree.tostring(fixture))