class TestBitlyAPIClientFunctions(unittest.TestCase): def setUp(self): self.api = API() self.parameters = { "login": "******", "apiKey": "R_thisismycrazyapikey", "longUrl": "http://www.bernardofontes.net", } def test_get_rest_method_parameters_return_expected_string(self): expected = "login=my_login&apiKey=R_thisismycrazyapikey&longUrl=http://www.bernardofontes.net" self.assertEquals(self.api._get_rest_method_parameters(self.parameters), expected) def test_get_api_method_parameters_url_works_for_shorten(self): expected = "http://api.bit.ly/v3/shorten?login=my_login&apiKey=R_thisismycrazyapikey&longUrl=http://www.bernardofontes.net" self.assertEquals(self.api._get_api_method_url("shorten", self.parameters), expected)
class TestBitlyAPIClientFunctions(unittest.TestCase): def setUp(self): self.api = API() self.parameters = { 'login': '******', 'apiKey': 'R_thisismycrazyapikey', 'longUrl': 'http://www.bernardofontes.net', } def test_get_rest_method_parameters_return_expected_string(self): expected = 'login=my_login&apiKey=R_thisismycrazyapikey&longUrl=http://www.bernardofontes.net' self.assertEquals(self.api._get_rest_method_parameters(self.parameters), expected) def test_get_rest_method_parameters_with_list_return_expected_string(self): self.parameters['listParam'] = ['value_1', 'value_2'] expected = 'listParam=value_1&listParam=value_2&login=my_login&apiKey=R_thisismycrazyapikey&longUrl=http://www.bernardofontes.net' self.assertEquals(self.api._get_rest_method_parameters(self.parameters), expected) def test_get_api_method_parameters_url_works_for_shorten(self): expected = 'http://api.bit.ly/v3/shorten?login=my_login&apiKey=R_thisismycrazyapikey&longUrl=http://www.bernardofontes.net' self.assertEquals(self.api._get_api_method_url('shorten', self.parameters), expected)