-
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): cover RacksDB unable errors
- Loading branch information
Showing
3 changed files
with
75 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2025 Rackslab | ||
# | ||
# This file is part of Slurm-web. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import sys | ||
from ..lib.agent import TestAgentBase | ||
|
||
|
||
class TestAgentApp(TestAgentBase): | ||
|
||
def test_app_loaded(self): | ||
# No error log must be emitted in this case. Note that assertNoLogs is available | ||
# starting from Python 3.10. For versions below, absence of logs is not checked. | ||
if sys.version_info < (3, 10): | ||
self.setup_client() | ||
else: | ||
with self.assertNoLogs("slurmweb", level="ERROR"): | ||
self.setup_client() | ||
|
||
def test_app_racksdb_format_error(self): | ||
with self.assertLogs("slurmweb", level="ERROR") as cm: | ||
self.setup_client(racksdb_format_error=True) | ||
self.assertEqual( | ||
cm.output, | ||
[ | ||
"ERROR:slurmweb.apps.agent:Unable to load RacksDB database: fake db " | ||
"format error" | ||
], | ||
) | ||
|
||
def test_app_racksdb_schema_error(self): | ||
with self.assertLogs("slurmweb", level="ERROR") as cm: | ||
self.setup_client(racksdb_schema_error=True) | ||
self.assertEqual( | ||
cm.output, | ||
[ | ||
"ERROR:slurmweb.apps.agent:Unable to load RacksDB schema: fake db " | ||
"schema error" | ||
], | ||
) |
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