<s> from unittest import TestCase <EOL> from datetime import datetime <EOL> from httpretty import HTTPretty <EOL> from httpretty import httprettified <EOL> from django_dynamic_fixture import G <EOL> from django . db . models . loading import get_model <EOL> from easyrec . gateway import EasyRec <EOL> from easyrec . errors import EasyRecException <EOL> Product = get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class GatewayTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . gateway = EasyRec ( "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT:key>' ) <EOL> self . maxDiff = <NUM_LIT:1000> <EOL> def test_base_url_is_checked ( self ) : <EOL> self . assertRaises ( RuntimeError , EasyRec , "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT:key>' ) <EOL> def test_get_url ( self ) : <EOL> expected = '<STR_LIT>' <EOL> url = self . gateway . _build_url ( '<STR_LIT:path>' ) <EOL> self . assertEqual ( expected , url ) <EOL> url = self . gateway . _build_url ( '<STR_LIT>' ) <EOL> self . assertEqual ( expected , url ) <EOL> url = self . gateway . _build_url ( '<STR_LIT>' ) <EOL> self . assertEqual ( expected , url ) <EOL> url = self . gateway . _build_url ( '<STR_LIT>' ) <EOL> self . assertEqual ( expected , url ) <EOL> @ httprettified <EOL> def test_get_item_types ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> item_types = self . gateway . get_item_types ( ) <EOL> self . assertEqual ( item_types , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ httprettified <EOL> def test_get_item_type ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> item_type = self . gateway . _get_item_type ( '<STR_LIT>' ) <EOL> self . assertEqual ( item_type , '<STR_LIT>' ) <EOL> item_type = self . gateway . _get_item_type ( '<STR_LIT>' ) <EOL> self . assertEqual ( item_type , '<STR_LIT>' ) <EOL> @ httprettified <EOL> def test_error_raises_exception ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> } <EOL> try : <EOL> self . gateway . add_view ( ** params ) <EOL> except EasyRecException as e : <EOL> self . assertEqual ( e . message , "<STR_LIT>" ) <EOL> @ httprettified <EOL> def test_add_view ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : datetime . now ( ) <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ '<STR_LIT>' ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ params [ "<STR_LIT>" ] . strftime ( "<STR_LIT>" ) ] , <EOL> } <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> self . gateway . add_view ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> @ httprettified <EOL> def test_add_buy ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : datetime . now ( ) <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ '<STR_LIT>' ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ params [ "<STR_LIT>" ] . strftime ( "<STR_LIT>" ) ] <EOL> } <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> self . gateway . add_buy ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> @ httprettified <EOL> def test_add_rating ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : <NUM_LIT:5> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : datetime . now ( ) <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ '<STR_LIT>' ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:5>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ params [ "<STR_LIT>" ] . strftime ( "<STR_LIT>" ) ] <EOL> } <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> self . gateway . add_rating ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> @ httprettified <EOL> def test_add_action ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT:action>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : datetime . now ( ) , <EOL> "<STR_LIT:value>" : <NUM_LIT:7> <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ '<STR_LIT>' ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ params [ "<STR_LIT>" ] . strftime ( "<STR_LIT>" ) ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> self . gateway . add_action ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( expected_get_params , get_params ) <EOL> @ httprettified <EOL> def test_get_user_recommendations ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:15> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_user_recommendations ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) <EOL> @ httprettified <EOL> def test_get_other_users_also_bought ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT:10> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_other_users_also_bought ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) <EOL> @ httprettified <EOL> def test_get_other_users_also_viewed ( self ) : <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_other_users_also_viewed ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) <EOL> @ httprettified <EOL> def test_get_items_rated_as_good_by_other_users ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_items_rated_as_good_by_other_users ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) <EOL> @ httprettified <EOL> def test_get_related_items ( self ) : <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_related_items ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) <EOL> @ httprettified <EOL> def test_get_most_viewed_items ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:1>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_most_viewed_items ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) <EOL> @ httprettified <EOL> def test_get_most_bought_items ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:1>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_most_bought_items ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) <EOL> @ httprettified <EOL> def test_get_most_rated_items ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:1>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_most_rated_items ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) <EOL> @ httprettified <EOL> def test_get_best_rated_items ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:1>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_best_rated_items ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) <EOL> @ httprettified <EOL> def test_get_worst_rated_items ( self ) : <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = '<STR_LIT>' , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> product = G ( Product , parent = None ) <EOL> params = { <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : '<STR_LIT>' <EOL> } <EOL> expected_get_params = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:key>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT:1>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> expected_response = '<STR_LIT>' % product . upc <EOL> HTTPretty . register_uri ( HTTPretty . GET , "<STR_LIT>" , <EOL> body = expected_response , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> response = self . gateway . get_worst_rated_items ( ** params ) <EOL> get_params = HTTPretty . last_request . querystring <EOL> self . assertEqual ( get_params , expected_get_params ) <EOL> self . assertEqual ( len ( response ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( response [ <NUM_LIT:0> ] [ '<STR_LIT>' ] . upc , product . upc ) </s>
