class TestUser(unittest.TestCase): def setUp(self): self.resource = Users("uri", ("username", "token")) def test_get(self): with patch.object(self.resource, "request") as mock_request: with patch.object(self.resource, "load_instance") as mock_load: mock_request.return_value = (Mock(), "{json instance}") self.resource.get() mock_request.assert_called_with("GET", self.resource.uri) mock_load.assert_called_with("{json instance}") def test_update(self): with patch.object(self.resource, "request") as mock: mock.return_value = (Mock(status=201), "{json instance}") result = self.resource.update( firstName="John", lastName="Doe", company="Company", timezone=1, ) mock.assert_called_with("PUT", self.resource.uri, data={ "firstName": "John", "lastName": "Doe", "company": "Company", "timezone": 1, }) self.assertTrue(result)
def setUp(self): self.resource = Users("uri", ("username", "token"))