-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(agent): racksdb routes when disabled/enabled
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright (c) 2025 Rackslab | ||
# | ||
# This file is part of Slurm-web. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
|
||
import textwrap | ||
|
||
from ..lib.agent import TestAgentBase | ||
|
||
|
||
class TestAgentRacksDBEnabledRequest(TestAgentBase): | ||
|
||
def setUp(self): | ||
self.setup_client() | ||
|
||
def test_request_racksdb(self): | ||
# Check FakeRacksDBWebBlueprint is called when racksdb is enabled (by default). | ||
response = self.client.get("/racksdb/fake") | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual( | ||
response.json, | ||
{"test": "ok"}, | ||
) | ||
|
||
|
||
class TestAgentRacksDBDisabledRequest(TestAgentBase): | ||
|
||
def setUp(self): | ||
self.setup_client( | ||
additional_conf=textwrap.dedent( | ||
""" | ||
[racksdb] | ||
enabled=no | ||
""" | ||
) | ||
) | ||
|
||
def test_request_racksdb(self): | ||
# Check FakeRacksDBWebBlueprint is not registered when racksdb is disabled. | ||
response = self.client.get("/racksdb/fake") | ||
self.assertEqual(response.status_code, 404) | ||
self.assertEqual( | ||
response.json, | ||
{ | ||
"code": 404, | ||
"description": ( | ||
"The requested URL was not found on the server. If you entered " | ||
"the URL manually please check your spelling and try again." | ||
), | ||
"name": "Not Found", | ||
}, | ||
) |