def test_bad_graph_call(self): with Stub() as urllib: from urllib import urlopen urlopen.__call__("https://graph.facebook.com/me", {}) >> StringIO("Bad JSON") response = self.policy.fbuser._make_graph_call("/me", {}) self.assertTrue(response == None)
def test_good_graph_call_no_params(self): with Stub() as urllib: from urllib import urlopen urlopen.__call__("https://graph.facebook.com/me", "") >> StringIO("{\"a\": \"b\"}") response = self.policy.fbuser._make_graph_call("/me") self.assertTrue(response['a'] == 'b')