Coverage for tests/endpoints/tests_get_stores.py: 100%
11 statements
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-05 22:06 +0000
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-05 22:06 +0000
1from unittest.mock import patch
3from tests.endpoints.endpoint_testing import TestEndpoints
6class TestGetStores(TestEndpoints):
7 @patch("canonicalwebteam.store_api.dashboard.Dashboard.get_stores")
8 def test_get_stores(self, mock_get_stores):
9 mock_get_stores.return_value = [
10 {"id": "ubuntu", "name": "Global", "roles": ["view", "access"]},
11 {
12 "id": "test-store",
13 "name": "Test Store",
14 "roles": ["admin", "review", "view", "access"],
15 },
16 ]
18 response = self.client.get("/api/stores")
19 data = response.get_json()
21 self.assertEqual(response.status_code, 200)
22 self.assertTrue(data["success"])
23 self.assertEqual(
24 data["data"],
25 [
26 {
27 "id": "ubuntu",
28 "name": "Global",
29 "roles": ["view", "access"],
30 },
31 {
32 "id": "test-store",
33 "name": "Test Store",
34 "roles": ["admin", "review", "view", "access"],
35 },
36 ],
37 )