Exemple #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)
     )
Exemple #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)
     )
Exemple #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))
Exemple #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))
Exemple #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)
     )
Exemple #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)
     )
Exemple #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'))
Exemple #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'))
Exemple #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'))
Exemple #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'))