def test_returning_invalid_auth(self): httpretty.register_uri(httpretty.GET, "https://mashape-community-urban-dictionary.p.mashape.com/define?term=python", body='', status=403) c = Client(API_key=INCORRECT_APIKEY) with self.assertRaises(APIError): c.get("python")
def test_request_body(self): httpretty.register_uri(httpretty.GET, "https://mashape-community-urban-dictionary.p.mashape.com/define?term=python", body=python_rbody, type='application/json', status=200) c = Client(CORRECT_APIKEY) resp = c.get("python") assert(len(resp) == 2) assert(len(resp.tags) == 4) assert(resp.word == "python") def1 = resp.definitions[0] assert(def1.author == "steak") assert(def1.defid == 192074) assert isinstance(def1.definition, str) assert isinstance(def1.example, str) assert def1.permalink.endswith(str(def1.defid)) assert isinstance(def1.time_acquired, datetime)