Пример #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 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])