예제 #1
0
 def test_client_update_unk_error(self):
     """Test the client response to not finding things."""
     endpoint_url = 'http://127.0.0.1:8080'
     class_type = 'users'
     params = {
         '_id': 127
     }
     post_body = {
         '_id': 127,
         'last_name': 'Doe',
         'first_name': 'John',
         'network_id': 'johndoe'
     }
     httpretty.register_uri(httpretty.POST, '{0}/{1}'.format(endpoint_url, class_type),
                            body='This is the error.',
                            status=301)
     client = PMClient(endpoint_url)
     try:
         client.update(class_type, params, post_body)
     except PMClientError as ex:
         self.assertEqual(str(ex), 'Unknown Error (301) This is the error.')
예제 #2
0
 def test_client_update_unk_error(self):
     """
     Test the client response to not finding things
     """
     endpoint_url = "http://127.0.0.1:8080"
     class_type = "users"
     params = {
         "_id": 127
     }
     post_body = {
         "_id": 127,
         "last_name": "Doe",
         "first_name": "John",
         "network_id": "johndoe"
     }
     httpretty.register_uri(httpretty.POST, "%s/%s"%(endpoint_url, class_type),
                            body="This is the error.",
                            status=301)
     client = PMClient(endpoint_url)
     try:
         client.update(class_type, params, post_body)
     except PMClientError, ex:
         self.assertEqual(str(ex), "Unknown Error (301) This is the error.")
예제 #3
0
 def test_client_update(self):
     """Test the client response to an unknown error."""
     endpoint_url = 'http://127.0.0.1:8080'
     class_type = 'users'
     params = {
         '_id': 127
     }
     response_body = {
         '_id': 127,
         'last_name': 'Doe',
         'first_name': 'John',
         'network_id': 'johndoe'
     }
     httpretty.register_uri(httpretty.POST, '{0}/{1}'.format(endpoint_url, class_type))
     client = PMClient(endpoint_url)
     response = client.update(class_type, params, response_body)
     self.assertTrue(response)
예제 #4
0
 def test_client_update(self):
     """
     Test the client response to an unknown error
     """
     endpoint_url = "http://127.0.0.1:8080"
     class_type = "users"
     params = {
         "_id": 127
     }
     response_body = {
         "_id": 127,
         "last_name": "Doe",
         "first_name": "John",
         "network_id": "johndoe"
     }
     httpretty.register_uri(httpretty.POST, "%s/%s"%(endpoint_url, class_type))
     client = PMClient(endpoint_url)
     response = client.update(class_type, params, response_body)
     self.assertTrue(response)
예제 #5
0
 def test_client_update_not_found(self):
     """Test the client response to not finding things."""
     endpoint_url = 'http://127.0.0.1:8080'
     class_type = 'users'
     params = {
         '_id': 127
     }
     response_body = {}
     post_body = {
         '_id': 127,
         'last_name': 'Doe',
         'first_name': 'John',
         'network_id': 'johndoe'
     }
     httpretty.register_uri(httpretty.POST, '{0}/{1}'.format(endpoint_url, class_type),
                            body=dumps(response_body),
                            content_type='application/json',
                            status=404)
     client = PMClient(endpoint_url)
     response = client.update(class_type, params, post_body)
     self.assertFalse(response)
예제 #6
0
 def test_client_update_not_found(self):
     """
     Test the client response to not finding things
     """
     endpoint_url = "http://127.0.0.1:8080"
     class_type = "users"
     params = {
         "_id": 127
     }
     response_body = {}
     post_body = {
         "_id": 127,
         "last_name": "Doe",
         "first_name": "John",
         "network_id": "johndoe"
     }
     httpretty.register_uri(httpretty.POST, "%s/%s"%(endpoint_url, class_type),
                            body=dumps(response_body),
                            content_type="application/json",
                            status=404)
     client = PMClient(endpoint_url)
     response = client.update(class_type, params, post_body)
     self.assertFalse(response)