@@ -68,8 +68,8 @@ def test_integration_ecommerce_transaction_item(self):
6868 with HTTMock (pass_response_content ):
6969 t .track_ecommerce_transaction_item ("12345" , "pbz0025" , 7.99 , 2 , "black-tarot" , "tarot" , currency = "GBP" )
7070 expected_fields = {"ti_ca" : "tarot" , "ti_id" : "12345" , "ti_qu" : "2" , "ti_sk" : "pbz0025" , "e" : "ti" , "ti_nm" : "black-tarot" , "ti_pr" : "7.99" , "ti_cu" : "GBP" }
71- for key in expected_fields :
72- self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
71+ for key in expected_fields :
72+ self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
7373
7474 def test_integration_ecommerce_transaction (self ):
7575 t = tracker .Tracker (default_consumer , default_subject )
@@ -86,55 +86,55 @@ def test_integration_ecommerce_transaction(self):
8686 "quantity" : 1
8787 }])
8888
89- expected_fields = {"e" : "tr" , "tr_id" : "6a8078be" , "tr_tt" : "35" , "tr_ci" : "London" , "tr_cu" : "GBP" }
90- for key in expected_fields :
91- self .assertEquals (from_querystring (key , querystrings [- 3 ]), expected_fields [key ])
89+ expected_fields = {"e" : "tr" , "tr_id" : "6a8078be" , "tr_tt" : "35" , "tr_ci" : "London" , "tr_cu" : "GBP" }
90+ for key in expected_fields :
91+ self .assertEquals (from_querystring (key , querystrings [- 3 ]), expected_fields [key ])
9292
93- expected_fields = {"e" : "ti" , "ti_id" : "6a8078be" , "ti_sk" : "pbz0026" , "ti_pr" : "20" , "ti_cu" : "GBP" }
94- for key in expected_fields :
95- self .assertEquals (from_querystring (key , querystrings [- 2 ]), expected_fields [key ])
93+ expected_fields = {"e" : "ti" , "ti_id" : "6a8078be" , "ti_sk" : "pbz0026" , "ti_pr" : "20" , "ti_cu" : "GBP" }
94+ for key in expected_fields :
95+ self .assertEquals (from_querystring (key , querystrings [- 2 ]), expected_fields [key ])
9696
97- expected_fields = {"e" : "ti" , "ti_id" : "6a8078be" , "ti_sk" : "pbz0038" , "ti_pr" : "15" , "ti_cu" : "GBP" }
98- for key in expected_fields :
99- self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
97+ expected_fields = {"e" : "ti" , "ti_id" : "6a8078be" , "ti_sk" : "pbz0038" , "ti_pr" : "15" , "ti_cu" : "GBP" }
98+ for key in expected_fields :
99+ self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
100100
101- for key in ["dtm" , "tid" ]:
102- self .assertEquals (from_querystring (key , querystrings [- 3 ]), from_querystring (key , querystrings [- 2 ]))
101+ for key in ["dtm" , "tid" ]:
102+ self .assertEquals (from_querystring (key , querystrings [- 3 ]), from_querystring (key , querystrings [- 2 ]))
103103
104104 def test_integration_screen_view (self ):
105105 t = tracker .Tracker (default_consumer , default_subject )
106106 with HTTMock (pass_response_content ):
107107 t .track_screen_view ("Game HUD 2" , "Hello!" )
108- expected_fields = {"e" : "ue" , "ue_na" : "screen_view" , "evn" : "com.snowplowanalytics" }
109- for key in expected_fields :
110- self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
108+ expected_fields = {"e" : "ue" , "ue_na" : "screen_view" , "evn" : "com.snowplowanalytics" }
109+ for key in expected_fields :
110+ self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
111111
112112 def test_integration_struct_event (self ):
113113 t = tracker .Tracker (default_consumer , default_subject )
114114 with HTTMock (pass_response_content ):
115115 t .track_struct_event ("Ecomm" , "add-to-basket" , "dog-skateboarding-video" , "hd" , 13.99 )
116- expected_fields = {"se_ca" : "Ecomm" , "se_pr" : "hd" , "se_la" : "dog-skateboarding-video" , "se_va" : "13.99" , "se_ac" : "add-to-basket" , "e" : "se" }
117- for key in expected_fields :
118- self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
116+ expected_fields = {"se_ca" : "Ecomm" , "se_pr" : "hd" , "se_la" : "dog-skateboarding-video" , "se_va" : "13.99" , "se_ac" : "add-to-basket" , "e" : "se" }
117+ for key in expected_fields :
118+ self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
119119
120120 def test_integration_unstruct_event_non_base64 (self ):
121121 t = tracker .Tracker (default_consumer , default_subject , encode_base64 = False )
122122 with HTTMock (pass_response_content ):
123123 t .track_unstruct_event ("com.example_company" , "viewed_product" , {"product_id" : "ASO01043" , "price$flt" : 49.95 , "walrus$tms" : int (time .time () * 1000 )})
124- expected_fields = {"e" : "ue" , "evn" : "com.example_company" , "ue_na" : "viewed_product" }
125- for key in expected_fields :
126- self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
124+ expected_fields = {"e" : "ue" , "evn" : "com.example_company" , "ue_na" : "viewed_product" }
125+ for key in expected_fields :
126+ self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
127127
128128 def test_integration_unstruct_event_base64 (self ):
129129 t = tracker .Tracker (default_consumer , default_subject )
130130 with HTTMock (pass_response_content ):
131131 t .track_unstruct_event ("com.example_company" , "viewed_product" , {"product_id" : "ASO01043" , "price$flt" : 49.95 , "walrus$tms" : int (time .time () * 1000 )})
132- expected_fields = {"e" : "ue" , "ue_na" : "viewed_product" }
133- for key in expected_fields :
134- self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
132+ expected_fields = {"e" : "ue" , "ue_na" : "viewed_product" }
133+ for key in expected_fields :
134+ self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
135135
136136 def test_integration_standard_nv_pairs (self ):
137- t = tracker .Tracker (default_consumer , default_subject , "cf" , app_id = "angry-birds-android" , context_vendor = "com.example" )
137+ t = tracker .Tracker (consumer . Consumer ( "localhost" ) , default_subject , "cf" , app_id = "angry-birds-android" , context_vendor = "com.example" )
138138 default_subject .set_platform ("mob" )
139139 default_subject .set_user_id ("user12345" )
140140 default_subject .set_screen_resolution (100 , 200 )
@@ -143,16 +143,16 @@ def test_integration_standard_nv_pairs(self):
143143 default_subject .set_lang ("en" )
144144 with HTTMock (pass_response_content ):
145145 t .track_page_view ("localhost" , "local host" , None , {'user' : {'user_type' : 'tester' }})
146- expected_fields = {"tna" : "cf" , "evn" : "com.snowplowanalytics" , "res" : "100x200" ,
147- "lang" : "en" , "aid" : "angry-birds-android" , "cd" : "24" , "tz" : "Europe+London" ,
148- "p" : "mob" , "tv" : "py-" + _version .__version__ , "cv" : "com.example" }
149- for key in expected_fields :
150- self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
146+ expected_fields = {"tna" : "cf" , "evn" : "com.snowplowanalytics" , "res" : "100x200" ,
147+ "lang" : "en" , "aid" : "angry-birds-android" , "cd" : "24" , "tz" : "Europe+London" ,
148+ "p" : "mob" , "tv" : "py-" + _version .__version__ , "cv" : "com.example" }
149+ for key in expected_fields :
150+ self .assertEquals (from_querystring (key , querystrings [- 1 ]), expected_fields [key ])
151151
152152 def test_integration_redis (self ):
153- t = tracker .Tracker (consumer .RedisConsumer (), default_subject )
154- t .track_page_view ("http://www.example.com" )
155153 r = redis .StrictRedis ()
154+ t = tracker .Tracker (consumer .RedisConsumer (rdb = r ), default_subject )
155+ t .track_page_view ("http://www.example.com" )
156156 event_string = r .rpop ("snowplow" )
157157 event_dict = json .loads (event_string .decode ("utf-8" ))
158158 self .assertEquals (event_dict ["e" ], "pv" )
@@ -163,12 +163,12 @@ def test_integration_success_callback(self):
163163 t = tracker .Tracker (callback_consumer , default_subject )
164164 with HTTMock (pass_response_content ):
165165 t .track_page_view ("http://www.example.com" )
166- self .assertEquals (callback_queue [0 ], 1 )
166+ self .assertEquals (callback_queue [0 ], 1 )
167167
168168 def test_integration_failure_callback (self ):
169169 callback_queue = []
170170 callback_consumer = consumer .Consumer ("localhost" , on_failure = lambda x , y : callback_queue .append (x ))
171171 t = tracker .Tracker (callback_consumer , default_subject )
172172 with HTTMock (fail_response_content ):
173173 t .track_page_view ("http://www.example.com" )
174- self .assertEquals (callback_queue [0 ], 0 )
174+ self .assertEquals (callback_queue [0 ], 0 )
0 commit comments