コード例 #1
0
def get_version(app_id, platform, channel, version, userid, date=None):
    try:
        new_version = _get_version(True,
                                   app_id,
                                   platform,
                                   channel,
                                   version,
                                   date=date)

        if not new_version:
            raise Version.DoesNotExist

        if new_version.partialupdate.exclude_new_users and is_new_user(
                version):
            raise Version.DoesNotExist

        if not is_user_active(new_version.partialupdate.active_users, userid):
            raise Version.DoesNotExist

        userid_int = UUID(userid).int
        percent = new_version.partialupdate.percent
        if not (userid_int % int(100 / percent)) == 0:
            raise Version.DoesNotExist
    except Version.DoesNotExist:
        new_version = _get_version(False,
                                   app_id,
                                   platform,
                                   channel,
                                   version,
                                   date=date)

    return new_version
コード例 #2
0
    def test_is_user_active(self):
        userid = "{F07B3878-CD6F-4B96-B52F-95C4D23077E0}"
        id = get_id(userid)

        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES["all"], userid))
        self.assertFalse(is_user_active(ACTIVE_USERS_DICT_CHOICES["week"], userid))
        self.assertFalse(is_user_active(ACTIVE_USERS_DICT_CHOICES["month"], userid))

        mark_event("request", id)

        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES["all"], userid))
        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES["week"], userid))
        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES["month"], userid))
コード例 #3
0
    def test_is_user_active(self):
        userid = '{F07B3878-CD6F-4B96-B52F-95C4D23077E0}'
        id = get_id(userid)

        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES['all'], userid))
        self.assertFalse(is_user_active(ACTIVE_USERS_DICT_CHOICES['week'], userid))
        self.assertFalse(is_user_active(ACTIVE_USERS_DICT_CHOICES['month'], userid))

        mark_event('request', id)

        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES['all'], userid))
        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES['week'], userid))
        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES['month'], userid))
コード例 #4
0
    def test_is_user_active(self):
        userid = '{F07B3878-CD6F-4B96-B52F-95C4D23077E0}'
        id = get_id(userid)

        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES['all'], userid))
        self.assertFalse(is_user_active(ACTIVE_USERS_DICT_CHOICES['week'], userid))
        self.assertFalse(is_user_active(ACTIVE_USERS_DICT_CHOICES['month'], userid))

        mark_event('request', id)

        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES['all'], userid))
        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES['week'], userid))
        self.assertTrue(is_user_active(ACTIVE_USERS_DICT_CHOICES['month'], userid))
コード例 #5
0
ファイル: builder.py プロジェクト: shashkin/omaha-server
def get_version(app_id, platform, channel, version, userid, date=None):
    try:
        new_version = _get_version(True, app_id, platform, channel, version, date=date)

        if not new_version:
            raise Version.DoesNotExist

        if new_version.partialupdate.exclude_new_users and is_new_user(version):
            raise Version.DoesNotExist

        if not is_user_active(new_version.partialupdate.active_users, userid):
            raise Version.DoesNotExist

        userid_int = UUID(userid).int
        percent = new_version.partialupdate.percent
        if not (userid_int % int(100 / percent)) == 0:
            raise Version.DoesNotExist
    except Version.DoesNotExist:
        new_version = _get_version(False, app_id, platform, channel, version, date=date)

    return new_version