-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add integration test for global_preferences
* The test container does not return the global_preferences file, so errors * Have added some exception handling to the function in case Marshmallow validation fails relates-to: #61
- Loading branch information
1 parent
766847a
commit 27635eb
Showing
3 changed files
with
16 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 |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import xmltodict | ||
from marshmallow import ValidationError | ||
|
||
from boinc_client.clients.rpc_client import RpcClient | ||
from boinc_client.models.generic_response import GenericResponse | ||
from boinc_client.models.global_preferences import GlobalPreferences | ||
|
||
|
||
def get_global_prefs_file(client: RpcClient) -> dict: | ||
"""Get the contents of the global_prefs.xml file if present.""" | ||
rpc_resp = client.make_request("<get_global_prefs_file/>") | ||
rpc_json = xmltodict.parse(rpc_resp) | ||
return GlobalPreferences().load(rpc_json) | ||
try: | ||
return GlobalPreferences().load(rpc_json) | ||
except ValidationError: | ||
return GenericResponse().load(rpc_json) |
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