💚 Fix unit tests
This commit is contained in:
1 parent
2222f1d204
commit
8c1111cfef
10 files changed
+91
-29
No files matched your search
@@ -1,12 +1,23 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from enum import Enum
|
||||
from typing import List
|
||||
|
||||
from octoprint.schema import BaseModel, Literal
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
|
||||
class ColorEnum(str, Enum):
|
||||
red = "red"
|
||||
orange = "orange"
|
||||
green = "green"
|
||||
blue = "blue"
|
||||
yellow = "yellow"
|
||||
violet = "violet"
|
||||
default = "default"
|
||||
|
||||
|
||||
@with_attrs_docs
|
||||
class ComponentOrderConfig(BaseModel):
|
||||
navbar: List[str] = [
|
||||
@@ -129,9 +140,7 @@ class AppearanceConfig(BaseModel):
|
||||
name: str = ""
|
||||
"""Use this to give your OctoPrint instance a name. It will be displayed in the title bar (as "<Name> [OctoPrint]") and in the navigation bar (as "OctoPrint: <>")"""
|
||||
|
||||
color: Literal[
|
||||
"red", "orange", "green", "blue", "yellow", "violet", "default"
|
||||
] = "default"
|
||||
color: ColorEnum = ColorEnum.default
|
||||
"""Use this to color the navigation bar."""
|
||||
|
||||
colorTransparent: bool = False
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from enum import Enum
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from octoprint.schema import BaseModel, Literal
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
|
||||
class LayoutEnum(str, Enum):
|
||||
horizontal = "horizontal"
|
||||
vertical = "vertical"
|
||||
|
||||
|
||||
class ControlSliderInputConfig(BaseModel):
|
||||
min: int = 0
|
||||
"""Minimum value of the slider."""
|
||||
@@ -40,7 +46,7 @@ class ContainerConfig(BaseModel):
|
||||
name: Optional[str] = None
|
||||
"""A name to display above the container, basically a section header."""
|
||||
|
||||
layout: Literal["horizontal", "vertical"] = "vertical"
|
||||
layout: LayoutEnum = LayoutEnum.vertical
|
||||
"""The layout to use for laying out the contained children, either from top to bottom (`vertical`) or from left to right (`horizontal`)."""
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from octoprint.schema import BaseModel, Literal
|
||||
from enum import Enum
|
||||
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
|
||||
class StylesheetEnum(str, Enum):
|
||||
css = "css"
|
||||
less = "less"
|
||||
|
||||
|
||||
@with_attrs_docs
|
||||
class DevelWebassetsConfig(BaseModel):
|
||||
bundle: bool = True
|
||||
@@ -30,7 +37,7 @@ class DevelCacheConfig(BaseModel):
|
||||
|
||||
@with_attrs_docs
|
||||
class DevelConfig(BaseModel):
|
||||
stylesheet: Literal["css", "less"] = "css"
|
||||
stylesheet: StylesheetEnum = StylesheetEnum.css
|
||||
"""Settings for stylesheet preference. OctoPrint will prefer to use the stylesheet type specified here. Usually (on a production install) that will be the compiled css (default). Developers may specify less here too."""
|
||||
|
||||
cache: DevelCacheConfig = DevelCacheConfig()
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from enum import Enum
|
||||
from typing import List, Optional
|
||||
|
||||
from octoprint.schema import BaseModel, Literal
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
|
||||
class SubscriptionTypeEnum(str, Enum):
|
||||
system = "system"
|
||||
gcode = "gcode"
|
||||
|
||||
|
||||
@with_attrs_docs
|
||||
class EventSubscription(BaseModel):
|
||||
event: str
|
||||
@@ -18,7 +24,7 @@ class EventSubscription(BaseModel):
|
||||
command: str
|
||||
"""The command to execute when the event is triggered, either a GCODE or a system command."""
|
||||
|
||||
type: Literal["system", "gcode"]
|
||||
type: SubscriptionTypeEnum
|
||||
"""The type of the command."""
|
||||
|
||||
enabled: bool = True
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from octoprint.schema import BaseModel, Literal
|
||||
from enum import Enum
|
||||
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
|
||||
class RunAtEnum(str, Enum):
|
||||
never = "never"
|
||||
idle = "idle"
|
||||
always = "always"
|
||||
|
||||
|
||||
@with_attrs_docs
|
||||
class GcodeAnalysisConfig(BaseModel):
|
||||
maxExtruders: int = 10
|
||||
@@ -19,7 +27,7 @@ class GcodeAnalysisConfig(BaseModel):
|
||||
throttle_lines: int = 100
|
||||
"""GCODE line batch size."""
|
||||
|
||||
runAt: Literal["never", "idle", "always"] = "idle"
|
||||
runAt: RunAtEnum = RunAtEnum.idle
|
||||
"""Whether to run the analysis only when idle (not printing), regardless of printing state or never."""
|
||||
|
||||
bedZ: float = 0.0
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from enum import Enum
|
||||
from typing import List, Optional
|
||||
|
||||
from octoprint.schema import BaseModel, Literal
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
|
||||
class AlwaysDetectNeverEnum(str, Enum):
|
||||
always = "always"
|
||||
detect = "detect"
|
||||
never = "never"
|
||||
|
||||
|
||||
class InfoWarnNeverEnum(str, Enum):
|
||||
info = "info"
|
||||
warn = "warn"
|
||||
never = "never"
|
||||
|
||||
|
||||
@with_attrs_docs
|
||||
class SerialTimeoutConfig(BaseModel):
|
||||
detectionFirst: float = 10.0
|
||||
@@ -159,7 +172,7 @@ class SerialConfig(BaseModel):
|
||||
logResends: bool = True
|
||||
"""Whether to log resends to octoprint.log or not. Invaluable debug tool without performance impact, leave on if possible please."""
|
||||
|
||||
supportResendsWithoutOk: Literal["always", "detect", "never"] = "detect"
|
||||
supportResendsWithoutOk: AlwaysDetectNeverEnum = AlwaysDetectNeverEnum.detect
|
||||
"""Whether to support resends without follow-up ok or not."""
|
||||
|
||||
logPositionOnPause: bool = True
|
||||
@@ -217,13 +230,13 @@ class SerialConfig(BaseModel):
|
||||
blockWhileDwelling: bool = False
|
||||
"""Whether to block all sending to the printer while a G4 (dwell) command is active (true, repetier) or not (false)."""
|
||||
|
||||
useParityWorkaround: Literal["always", "detect", "never"] = "detect"
|
||||
useParityWorkaround: AlwaysDetectNeverEnum = AlwaysDetectNeverEnum.detect
|
||||
maxConsecutiveResends: int = 10
|
||||
sendM112OnError: bool = True
|
||||
disableSdPrintingDetection: bool = False
|
||||
ackMax: int = 1
|
||||
sanityCheckTools: bool = True
|
||||
notifySuppressedCommands: Literal["info", "warn", "never"] = "warn"
|
||||
notifySuppressedCommands: InfoWarnNeverEnum = InfoWarnNeverEnum.warn
|
||||
capabilities: SerialCapabilities = SerialCapabilities()
|
||||
|
||||
resendRatioThreshold: int = 10
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from enum import Enum
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from octoprint.schema import BaseModel, Literal
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
CONST_15MIN = 15 * 60
|
||||
@@ -13,6 +14,12 @@ CONST_200MB = 200 * 1024 * 1024
|
||||
CONST_100KB = 100 * 1024
|
||||
|
||||
|
||||
class SameSiteEnum(str, Enum):
|
||||
lax = "Lax"
|
||||
strict = "Strict"
|
||||
none = "None"
|
||||
|
||||
|
||||
@with_attrs_docs
|
||||
class ReverseProxyConfig(BaseModel):
|
||||
prefixHeader: Optional[str] = None
|
||||
@@ -137,7 +144,7 @@ class CookiesConfig(BaseModel):
|
||||
secure: bool = False
|
||||
"""Whether to set the `Secure` flag to true on cookies. Only set to true if you are running OctoPrint behind a reverse proxy taking care of SSL termination."""
|
||||
|
||||
samesite: Optional[Literal["Strict", "Lax", "None"]] = "Lax"
|
||||
samesite: SameSiteEnum = SameSiteEnum.lax
|
||||
"""`SameSite` setting to use on the cookies. Possible values are `None`, `Lax` and `Strict`. Defaults to `Lax`. Be advised that if forced unset, this has security implications as many browsers now default to `Lax` unless you configure cookies to be set with `Secure` flag set, explicitly set `SameSite` setting here and also serve OctoPrint over https. The `Lax` setting is known to cause with embedding OctoPrint in frames. See also ["Feature: Cookies default to SameSite=Lax"](https://www.chromestatus.com/feature/5088147346030592), ["Feature: Reject insecure SameSite=None cookies"](https://www.chromestatus.com/feature/5633521622188032) and [issue #3482](https://github.com/OctoPrint/OctoPrint/issues/3482)."""
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
from octoprint.schema import BaseModel, Literal
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
|
||||
class TimelapseTypeEnum(str, Enum):
|
||||
off = "off"
|
||||
zchange = "zchange"
|
||||
timed = "timed"
|
||||
|
||||
|
||||
@with_attrs_docs
|
||||
class TimelapseOptions(BaseModel):
|
||||
interval: Optional[int] = None
|
||||
@@ -21,7 +28,7 @@ class TimelapseOptions(BaseModel):
|
||||
|
||||
@with_attrs_docs
|
||||
class TimelapseConfig(BaseModel):
|
||||
type: Literal["off", "zchange", "timed"] = "off"
|
||||
type: TimelapseTypeEnum = TimelapseTypeEnum.off
|
||||
"""The timelapse type."""
|
||||
|
||||
fps: int = 25
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from enum import Enum
|
||||
from typing import List, Optional
|
||||
|
||||
from octoprint.schema import BaseModel, Literal
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
|
||||
class RatioEnum(str, Enum):
|
||||
sixteen_nine = "16:9"
|
||||
four_three = "4:3"
|
||||
|
||||
|
||||
@with_attrs_docs
|
||||
class WebcamCompatibility(BaseModel):
|
||||
streamTimeout: int = 5
|
||||
"""The timeout of the stream in seconds"""
|
||||
|
||||
streamRatio: Literal["16:9", "4:3"] = "16:9"
|
||||
streamRatio: RatioEnum = RatioEnum.sixteen_nine
|
||||
"""The stream's native aspect ratio"""
|
||||
|
||||
streamWebrtcIceServers: List[str] = ["stun:stun.l.google.com:19302"]
|
||||
|
||||
@@ -372,10 +372,3 @@ def test_logfile_path_with_postfix(plugin_settings, settings):
|
||||
|
||||
settings.getBaseFolder.assert_called_once_with("logs")
|
||||
assert f"/some/folder/plugin_{plugin_key}_mypostfix.log" == path.replace(os.sep, "/")
|
||||
|
||||
|
||||
def test_unhandled_method(plugin_settings):
|
||||
with pytest.raises(
|
||||
AttributeError, match="Mock object has no attribute 'some_method'"
|
||||
):
|
||||
plugin_settings.some_method("some_parameter")
|
||||
Reference in new issue
Block a user