1+ import logging
12import sys
23import unittest
34import usabilla as ub
67from unittest import TestCase , main as unittest_main
78
89
9- import logging
10-
1110logging .basicConfig (level = logging .DEBUG )
1211
12+
1313class TestCredentials (TestCase ):
1414
1515 def setUp (self ):
@@ -66,18 +66,15 @@ def test_client_constants(self):
6666 self .assertEqual (self .client .host_protocol , 'https://' )
6767 self .assertEqual ('' ,self .client .query_parameters )
6868
69-
7069 def test_sign_key (self ):
7170 signed_key = self .client .sign (self .secret_key .encode ('utf-8' ), 'usbl1_request' .encode ('utf-8' ))
7271 self .assertEqual (signed_key , b"&-\x88 \x80 Z9\xe8 Pnvx\xe4 S\xee Z\x9f G\xc5 \xf7 g\x11 |\xc1 \xaa ~q(\xef \xaf \x95 \xc0 \xac " )
7372
74-
7573 def test_get_signature_key (self ):
7674 datestamp = '20150115'
7775 signing_key = self .client .get_signature_key (self .secret_key , datestamp )
7876 self .assertEqual (signing_key , b"\x15 \x8d \xd7 U\xce G\xde H\x8a HwU\xf5 qg\xae \xd4 Z\x19 `\xed M\x80 \x87 \x97 V\xbf \xe9 pw\xaa \xae " )
7977
80-
8178 def test_query_parameters (self ):
8279 params = {'limit' : 1 }
8380 self .client .set_query_parameters (params )
@@ -88,12 +85,32 @@ def test_query_parameters(self):
8885
8986 def test_check_resource_validity (self ):
9087 with self .assertRaises (ub .GeneralError ):
91- self .client .check_resource_validity ('nonexisting' , 'nonexisting' , 'nonexisting' )
88+ self .client .check_resource_validity (
89+ 'nonexisting' ,
90+ 'nonexisting' ,
91+ 'nonexisting' )
9292 with self .assertRaises (ub .GeneralError ):
93- self .client .check_resource_validity ('live' , 'nonexisting' , 'nonexisting' )
93+ self .client .check_resource_validity (
94+ 'live' ,
95+ 'nonexisting' ,
96+ 'nonexisting' )
9497 with self .assertRaises (ub .GeneralError ):
95- self .client .check_resource_validity ('live' , 'websites' , 'nonexisting' )
96- self .assertEqual (self .client .check_resource_validity ('live' , 'websites' , 'button' ), '/live/websites/button' )
98+ self .client .check_resource_validity (
99+ 'live' ,
100+ 'websites' ,
101+ 'nonexisting' )
102+ self .assertEqual (
103+ self .client .check_resource_validity ('live' , 'websites' , 'button' ),
104+ '/live/websites/button' )
105+ self .assertEqual (
106+ self .client .check_resource_validity ('live' , 'apps' , 'campaign' ),
107+ '/live/apps/campaign' )
108+ self .assertEqual (
109+ self .client .check_resource_validity (
110+ 'live' ,
111+ 'apps' ,
112+ 'campaign_result' ),
113+ '/live/apps/campaign/:id/results' )
97114
98115 def test_handle_id (self ):
99116 url = '/live/websites/button/:id/feedback'
0 commit comments