Exemplo n.º 1
0
    def test_update_live_statistics_updatecheck(self):
        request = parse_request(fixtures.request_update_check)
        apps = request.findall('app')
        app = apps[0]

        now = datetime.utcnow()
        userid = 1
        platform = 'win'

        appid = app.get('appid')
        version = app.get('version')

        events_appid_version = HourEvents('online:{}:{}'.format(appid, version), now.year, now.month, now.day, now.hour)
        events_appid_platform_version = HourEvents('online:{}:{}:{}'.format(appid, platform, version), now.year, now.month, now.day, now.hour)

        self.assertEqual(len(events_appid_version), 0)
        self.assertEqual(len(events_appid_platform_version), 0)

        update_live_statistics(userid, apps, platform)

        self.assertEqual(len(events_appid_version), 1)
        self.assertEqual(len(events_appid_platform_version), 1)
Exemplo n.º 2
0
    def test_update_live_statistics_install(self):
        request = parse_request(fixtures.request_event_install_success)
        apps = request.findall('app')
        app = apps[0]

        now = datetime.utcnow()
        userid = 1
        platform = 'win'

        appid = app.get('appid')
        version_1 = '0.0.0.1'
        version_2 = '0.0.0.2'

        events_appid_version_1 = HourEvents('online:{}:{}'.format(appid, version_1), now.year, now.month, now.day, now.hour)
        events_appid_platform_version_1 = HourEvents('online:{}:{}:{}'.format(appid, platform, version_1), now.year, now.month, now.day, now.hour)

        self.assertEqual(len(events_appid_version_1), 0)
        self.assertEqual(len(events_appid_platform_version_1), 0)

        update_live_statistics(userid, apps, platform)

        self.assertEqual(len(events_appid_version_1), 1)
        self.assertEqual(len(events_appid_platform_version_1), 1)

        request = parse_request(fixtures.request_event_update_success)
        apps = request.findall('app')

        update_live_statistics(userid, apps, platform)

        events_appid_version_1 = HourEvents('online:{}:{}'.format(appid, version_1), now.year, now.month, now.day, now.hour)
        events_appid_platform_version_1 = HourEvents('online:{}:{}:{}'.format(appid, platform, version_1), now.year, now.month, now.day, now.hour)
        events_appid_version_2 = HourEvents('online:{}:{}'.format(appid, version_2), now.year, now.month, now.day, now.hour)
        events_appid_platform_version_2 = HourEvents('online:{}:{}:{}'.format(appid, platform, version_2), now.year, now.month, now.day, now.hour)

        self.assertEqual(len(events_appid_version_1), 0)
        self.assertEqual(len(events_appid_platform_version_1), 0)
        self.assertEqual(len(events_appid_version_2), 1)
        self.assertEqual(len(events_appid_platform_version_2), 1)

        request = parse_request(fixtures.request_event_uninstall_success)
        apps = request.findall('app')

        update_live_statistics(userid, apps, platform)

        events_appid_version_2 = HourEvents('online:{}:{}'.format(appid, version_2),
                                            now.year, now.month, now.day, now.hour)
        events_appid_platform_version_2 = HourEvents('online:{}:{}:{}'.format(appid, platform, version_2),
                                                     now.year, now.month, now.day, now.hour)

        self.assertEqual(len(events_appid_version_2), 1)
        self.assertEqual(len(events_appid_platform_version_2), 1)