-
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
3 changed files
with
84 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
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,53 @@ | ||
# 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 | ||
from ..lib.utils import flask_404_description | ||
|
||
|
||
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": flask_404_description, | ||
"name": "Not Found", | ||
}, | ||
) |