diff options
author | Andrey Mekin <anmekin@gmail.com> | 2016-12-01 14:53:19 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-01 14:53:19 +0700 |
commit | df17ee6534c30a24f4804fea1ccf423ea83fb0c8 (patch) | |
tree | 2782ab43aa413a64f503e4232001e6d4aabdd9bc /omaha_server/sparkle/tests/test_statistics.py | |
parent | 9e468645314a1a9f5108e492fc0906b52638964f (diff) | |
parent | 750171bc8af9dbed72d2f3369a31544a27fd7804 (diff) | |
download | omaha-server-origin/dev.zip omaha-server-origin/dev.tar.gz omaha-server-origin/dev.tar.bz2 |
Merge pull request #235 from anmekin/feature/upd_live_statisticsorigin/dev
Add 6 month capability for Live Statistics
Diffstat (limited to 'omaha_server/sparkle/tests/test_statistics.py')
-rw-r--r-- | omaha_server/sparkle/tests/test_statistics.py | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/omaha_server/sparkle/tests/test_statistics.py b/omaha_server/sparkle/tests/test_statistics.py index efd017d..18febb8 100644 --- a/omaha_server/sparkle/tests/test_statistics.py +++ b/omaha_server/sparkle/tests/test_statistics.py @@ -27,8 +27,7 @@ from bitmapist import DayEvents, HourEvents from freezegun import freeze_time from omaha.utils import get_id -from sparkle.statistics import update_live_statistics, collect_statistics -from sparkle.statistics import add_app_statistics +from sparkle.statistics import add_app_statistics, userid_counting redis = get_redis_connection('statistics') @@ -121,47 +120,34 @@ class StatisticsTest(TestCase): appid = '{F97917B1-19AB-48C1-9802-CEF305B10804}' version = '0.0.0.1' + test_app = dict(appid=appid, version=version) + platform = 'mac' - request_version_events = HourEvents('online:{}:{}'.format(appid, version)) - request_platform_version_events = HourEvents('online:{}:{}:{}'.format(appid, 'mac', version)) + request_version_events = HourEvents('request:{}:{}'.format(appid, version)) + request_platform_version_events = HourEvents('request:{}:{}:{}'.format(appid, 'mac', version)) self.assertFalse(user1_id in request_version_events) self.assertEqual(len(request_version_events), 0) self.assertFalse(user1_id in request_platform_version_events) self.assertEqual(len(request_platform_version_events), 0) - update_live_statistics(userid1, appid, version) + userid_counting(userid1, test_app, platform) self.assertTrue(user1_id in request_version_events) self.assertEqual(len(request_version_events), 1) self.assertTrue(user1_id in request_platform_version_events) self.assertEqual(len(request_platform_version_events), 1) - update_live_statistics(userid1, appid, version) + userid_counting(userid1, test_app, platform) self.assertTrue(user1_id in request_version_events) self.assertEqual(len(request_version_events), 1) self.assertTrue(user1_id in request_platform_version_events) self.assertEqual(len(request_platform_version_events), 1) - update_live_statistics(userid2, appid, version) + userid_counting(userid2, test_app, platform) self.assertTrue(user2_id in request_version_events) self.assertEqual(len(request_version_events), 2) self.assertTrue(user2_id in request_platform_version_events) self.assertEqual(len(request_platform_version_events), 2) - - @mock.patch('sparkle.statistics.update_live_statistics') - def test_collect_statistics(self, mock_update_live_statistics): - app_id = '00000000-0000-0000-0000-000000000001' - app_name = "Sparrow" - channel = "test" - version = "0.0.0.1" - deviceID = "A37152BF-A3CB-5FEC-8230-FACF43BDCDDD" - request = RequestFactory().get('/sparkle/%s/%s/appcast.xml?appVersionShort=%s&deviceID=%s' % - (app_name, channel, version, deviceID)) - - collect_statistics(request, app_id, channel) - - mock_update_live_statistics.assert_called_with(deviceID, app_id, version) - |