예제 #1
0
    def call_rank(self, client, cfg, aid, customer, entity):
        view, ids = json.loads(entity).popitem()

        p = RankingParams()
        p.anonymous = aid
        p.customer = customer
        p.view = view
        p.ids = ids
        p.application = cfg['application']
        p.entity_type = cfg['entityType']

        log.debug('Running client.get_rankings("%s", "%s", "%s", {...})' % (p.anonymous, p.customer, p.view))

        return client.get_rankings(p, oauth_token=cfg['authToken'])
예제 #2
0
    def test_get_rankings(self):
        """
        Verify that the rankings returned on a get call happened correctly and the size of the
        list matches the list supplied in the params
        """

        anonymous = self.client.create_anonymous(oauth_token=self.oauth_token)
        self.assertIsNotNone(anonymous)

        params = RankingParams()
        params.anonymous = "an-anon-id"
        params.view = "b/mens-pants"
        params.entity_type = "products"
        params.ids = self.with_default_id_list

        rankings = self.client.get_rankings(params, oauth_token=self.oauth_token)
        self.assertEqual(len(rankings.ranking), len(params.ids))

        self.client.update_fallback_to_default(True)

        defaultList = self.client.get_rankings(params, oauth_token=self.oauth_token)
        self.assertEqual(self.with_default_id_list[0], defaultList.ranking[0])
예제 #3
0
    def make_scope_ranking_call(self, sale_id, id_list):
        rankingParams = RankingParams()
        rankingParams.anonymous = 'some-anon-id'
        rankingParams.view = "/sales/" + sale_id
        rankingParams.entity_source = "scope"

        def entry(name, value):
            item = ScopeEntry()
            item.name = name
            item.value = value

            return item

        rankingParams.scope = [
            entry('sale', sale_id),
            entry('color', 'red'),
            entry('size', 'M')
        ]

        rankingParams.entity_type = "products"
        rankingParams.application = "mobile_event_page"

        return self.client.get_rankings(rankingParams,
                                        oauth_token=self.oauth_token)
예제 #4
0
    def make_scope_ranking_call(self, sale_id, id_list):
        rankingParams = RankingParams()
        rankingParams.anonymous = 'some-anon-id'
        rankingParams.view = "/sales/" + sale_id
        rankingParams.entity_source = "scope"

        def entry(name, value):
            item = ScopeEntry()
            item.name = name
            item.value = value

            return item

        rankingParams.scope = [
            entry('sale', sale_id),
            entry('color', 'red'),
            entry('size', 'M')
        ]

        rankingParams.entity_type = "products"
        rankingParams.application = "mobile_event_page"

        return self.client.get_rankings(rankingParams, oauth_token=self.oauth_token)
예제 #5
0
    def test_get_rankings(self):
        """
        Verify that the rankings returned on a get call happened correctly and the size of the
        list matches the list supplied in the params
        """

        anonymous = self.client.create_anonymous(oauth_token=self.oauth_token)
        self.assertIsNotNone(anonymous)

        params = RankingParams()
        params.anonymous = "an-anon-id"
        params.view = "b/mens-pants"
        params.entity_type = "products"
        params.ids = self.with_default_id_list

        rankings = self.client.get_rankings(params,
                                            oauth_token=self.oauth_token)
        self.assertEqual(len(rankings.ranking), len(params.ids))

        self.client.update_fallback_to_default(True)

        defaultList = self.client.get_rankings(params,
                                               oauth_token=self.oauth_token)
        self.assertEqual(self.with_default_id_list[0], defaultList.ranking[0])