Skip to content

Commit 57f1bfe

Browse files
committed
Refactor tests
1 parent 1f1c52c commit 57f1bfe

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/daprojects_python/tests.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import resources
88

99

10-
class TestDAPCLient(unittest.TestCase):
10+
class TestClient(unittest.TestCase):
1111

1212
def test_set_base_url(self):
1313
client.set_host('https://example.com:9090')
@@ -17,10 +17,12 @@ def test_set_base_url(http://github.com/self):
1717
mock_response.json.return_value = []
1818
mock_requests_get.return_value = mock_response
1919

20-
projects = resources.list_projects()
20+
some_resources = client.list_resources(client.base_url + '/some_resources/')
21+
22+
mock_requests_get.assert_called_once_with('https://example.com:9090/api/v1/some_resources/')
23+
self.assertEqual(len(some_resources), 0)
2124

22-
mock_requests_get.assert_called_once_with('https://example.com:9090/api/v1/projects/')
23-
self.assertEqual(len(projects), 0)
25+
client.set_host('http://localhost:8000')
2426

2527
def test_error_checking(self):
2628
with patch('client.requests.get') as mock_requests_get:
@@ -29,10 +31,13 @@ def test_error_checking(self):
2931
mock_requests_get.return_value = mock_response
3032

3133
with self.assertRaises(exceptions.RequestException):
32-
projects = resources.list_projects()
34+
some_resources = client.list_resources(client.base_url + '/some_resources/')
3335

3436
mock_response.raise_for_status.assert_called_once()
3537

38+
39+
class TestProjects(unittest.TestCase):
40+
3641
def test_list_projects(self):
3742
with patch('client.requests.get') as mock_requests_get:
3843
mock_response = Mock()

0 commit comments

Comments
 (0)