Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/labthings_fastapi/thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
# Load the key from the JSON file using the setting's model
setting.set_without_emit(setting.validate(value))
except ValidationError:
self.logger.warning(

Check warning on line 262 in src/labthings_fastapi/thing.py

View workflow job for this annotation

GitHub Actions / coverage

262 line is not covered with tests
f"Could not load setting {name} from settings file "
f"because of a validation error.",
exc_info=True,
Expand All @@ -279,7 +279,7 @@
the settings file every time.
"""
if self._disable_saving_settings:
return

Check warning on line 282 in src/labthings_fastapi/thing.py

View workflow job for this annotation

GitHub Actions / coverage

282 line is not covered with tests
# We dump to a string first, to avoid corrupting the file if it fails
setting_json = self.settings.model_instance.model_dump_json(indent=4)
path = self._thing_server_interface.settings_file_path
Expand Down Expand Up @@ -331,9 +331,9 @@
Some measure of caching here is a nice aim for the future, but not yet
implemented.
"""
if self._labthings_thing_state is None:
self._labthings_thing_state = {}
return self._labthings_thing_state

Check warning on line 336 in src/labthings_fastapi/thing.py

View workflow job for this annotation

GitHub Actions / coverage

334-336 lines are not covered with tests

def validate_thing_description(self) -> None:
"""Raise an exception if the thing description is not valid."""
Expand Down Expand Up @@ -365,7 +365,7 @@
and self._cached_thing_description[0] == path
and self._cached_thing_description[1] == base
):
return self._cached_thing_description[2]

Check warning on line 368 in src/labthings_fastapi/thing.py

View workflow job for this annotation

GitHub Actions / coverage

368 line is not covered with tests

properties = {}
actions = {}
Expand All @@ -377,6 +377,7 @@

td = ThingDescription(
title=getattr(self, "title", self.__class__.__name__),
description=self.__doc__,
properties=properties,
actions=actions,
security="no_security",
Expand Down Expand Up @@ -453,7 +454,7 @@
inv_id = get_invocation_id()
server = self._thing_server_interface._server()
if server is None:
raise RuntimeError("Could not get server from thing_server_interface")

Check warning on line 457 in src/labthings_fastapi/thing.py

View workflow job for this annotation

GitHub Actions / coverage

457 line is not covered with tests
action_manager = server.action_manager
this_invocation = action_manager.get_invocation(inv_id)
return this_invocation.log
4 changes: 4 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def test_server_thing_descriptions():

for thing_name in thing_names:
thing_description = thing_descriptions[thing_name]

expected_description = "An example Thing with a few affordances."
assert thing_description["description"] == expected_description

for action_name in actions:
action = thing_description["actions"][action_name]
expected_href = thing_name + "/" + action_name
Expand Down
Loading