def test_bad_response(self, http): http.return_value = BadResponse('the url', 'some err') with self.assertRaises(RuntimeError) as ctx: _get_json_for_fragment({'node-url': 'http://localhost:1234'}, '/fragment') self.assertTrue( "Failed to get" in str(ctx.exception) )
def test_bad_response(self, http): http.return_value = BadResponse('the url', 'some err') with self.assertRaises(RuntimeError) as ctx: _get_json_for_fragment({'node-url': 'http://localhost:1234'}, '/fragment') self.assertTrue( "Failed to get" in str(ctx.exception) )
def test_post_args_for_get(self): with self.assertRaises(ValueError) as ctx: _get_json_for_fragment({'node-url': 'http://localhost:1234'}, '/fragment', method='GET', post_args={'foo': 'bar'}) self.assertTrue("only valid for POST" in str(ctx.exception))
def test_no_post_args(self): with self.assertRaises(ValueError) as ctx: _get_json_for_fragment( {'node-url': 'http://localhost:1234'}, '/fragment', method='POST', post_args=None, ) self.assertTrue("Must pass post_args" in str(ctx.exception))
def test_post_args_for_get(self): with self.assertRaises(ValueError) as ctx: _get_json_for_fragment( {'node-url': 'http://localhost:1234'}, '/fragment', method='GET', post_args={'foo': 'bar'} ) self.assertTrue( "only valid for POST" in str(ctx.exception) )
def test_no_post_args(self): with self.assertRaises(ValueError) as ctx: _get_json_for_fragment( {'node-url': 'http://localhost:1234'}, '/fragment', method='POST', post_args=None, ) self.assertTrue( "Must pass post_args" in str(ctx.exception) )
def test_happy_path_post(self, http): http.return_value = StringIO('{"some": "json"}') resp = _get_json_for_fragment({'node-url': 'http://localhost:1234/'}, '/fragment/', method='POST', post_args={'foo': 'bar'}) self.assertEqual(resp, dict(some='json'))
def test_happy_path_post(self, http): http.return_value = StringIO('{"some": "json"}') resp = _get_json_for_fragment( {'node-url': 'http://localhost:1234/'}, '/fragment/', method='POST', post_args={'foo': 'bar'} ) self.assertEqual(resp, dict(some='json'))
def test_happy_path(self, http): http.return_value = StringIO('{"some": "json"}') resp = _get_json_for_fragment({'node-url': 'http://localhost:1234/'}, '/fragment/') self.assertEqual(resp, dict(some='json'))
def test_happy_path(self, http): http.return_value = StringIO('{"some": "json"}') resp = _get_json_for_fragment({'node-url': 'http://localhost:1234/'}, '/fragment/') self.assertEqual(resp, dict(some='json'))