Fix tests and workaround issue with flake8

This commit is contained in:
grossmj committed 2021-10-18 22:12:10 +10:30
1 parent 01da25a7c7
commit 88d98cf02e
3 files changed
+9 -11

No files matched your search

+5 -6
View File
@@ -298,19 +298,18 @@ class ApplianceManager:
path = os.path.join(directory, file)
try:
with open(path, encoding="utf-8") as f:
json_data = json.load(f)
schemas.Appliance.parse_obj(json_data)
appliance = Appliance(path, json_data, builtin=builtin)
appliance_data = appliance.asdict() # Check if loaded without error
appliance = Appliance(path, json.load(f), builtin=builtin)
json_data = appliance.asdict() # Check if loaded without error
if appliance.status != "broken":
schemas.Appliance.parse_obj(json_data)
self._appliances[appliance.id] = appliance
if not appliance.symbol or appliance.symbol.startswith(":/symbols/"):
# apply a default symbol if the appliance has none or a default symbol
default_symbol = self._get_default_symbol(appliance_data, symbol_theme)
default_symbol = self._get_default_symbol(json_data, symbol_theme)
if default_symbol:
appliance.symbol = default_symbol
except (ValueError, OSError, KeyError, ValidationError) as e:
log.warning(f"Cannot load appliance file '{path}': {e}")
print(f"Cannot load appliance file '{path}': {e}")
continue
def _get_default_symbol(self, appliance: dict, symbol_theme: str) -> str:
+2 -2
View File
@@ -323,7 +323,7 @@ class Image(BaseModel):
filename: str = Field(..., title='Filename')
version: str = Field(..., title='Version of the file')
md5sum: constr(regex=r'^[a-f0-9]{32}$') = Field(..., title='md5sum of the file')
md5sum: str = Field(..., title='md5sum of the file', regex='^[a-f0-9]{32}$')
filesize: int = Field(..., title='File size in bytes')
download_url: Optional[Union[AnyUrl, constr(max_length=0)]] = Field(
None, title='Download url where you can download the appliance from a browser'
@@ -353,7 +353,7 @@ class Images(BaseModel):
class Version(BaseModel):
name: str = Field(..., title='Name of the version')
idlepc: Optional[constr(regex=r'^0x[0-9a-f]{8}')] = None
idlepc: Optional[str] = Field(None, regex='^0x[0-9a-f]{8}')
images: Optional[Images] = Field(None, title='Images used for this version')