Ejemplo n.º 1
0
 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)
     )
Ejemplo n.º 2
0
 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)
     )
Ejemplo n.º 3
0
 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))
Ejemplo n.º 4
0
 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))
Ejemplo n.º 5
0
 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)
     )
Ejemplo n.º 6
0
 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)
     )
Ejemplo n.º 7
0
 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'))
Ejemplo n.º 8
0
 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'))
Ejemplo n.º 9
0
 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'))
Ejemplo n.º 10
0
 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'))