-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
caaffb1
commit b97ca2d
Showing
14 changed files
with
177 additions
and
0 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
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,36 @@ | ||
from enum import auto | ||
from typing import List | ||
|
||
from gw.enums import GwStrEnum | ||
|
||
|
||
class AdminEvent(GwStrEnum): | ||
""" | ||
Values: | ||
- WakeUp | ||
- GoDormant | ||
For more information: | ||
- [ASLs](https://gridworks-type-registry.readthedocs.io/en/latest/) | ||
- [Global Authority](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#adminevent) | ||
""" | ||
|
||
WakeUp = auto() | ||
GoDormant = auto() | ||
|
||
@classmethod | ||
def default(cls) -> "AdminEvent": | ||
return cls.WakeUp | ||
|
||
@classmethod | ||
def values(cls) -> List[str]: | ||
return [elt.value for elt in cls] | ||
|
||
@classmethod | ||
def enum_name(cls) -> str: | ||
return "admin.event" | ||
|
||
@classmethod | ||
def enum_version(cls) -> str: | ||
return "000" |
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,36 @@ | ||
from enum import auto | ||
from typing import List | ||
|
||
from gw.enums import GwStrEnum | ||
|
||
|
||
class AdminState(GwStrEnum): | ||
""" | ||
Values: | ||
- Awake | ||
- Dormant | ||
For more information: | ||
- [ASLs](https://gridworks-type-registry.readthedocs.io/en/latest/) | ||
- [Global Authority](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#adminstate) | ||
""" | ||
|
||
Awake = auto() | ||
Dormant = auto() | ||
|
||
@classmethod | ||
def default(cls) -> "AdminState": | ||
return cls.Dormant | ||
|
||
@classmethod | ||
def values(cls) -> List[str]: | ||
return [elt.value for elt in cls] | ||
|
||
@classmethod | ||
def enum_name(cls) -> str: | ||
return "admin.state" | ||
|
||
@classmethod | ||
def enum_version(cls) -> str: | ||
return "000" |
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Type go.dormant, version 000""" | ||
|
||
from typing import Literal | ||
|
||
from pydantic import BaseModel | ||
|
||
from gwproto.property_format import SpaceheatName | ||
|
||
|
||
class GoDormant(BaseModel): | ||
ToName: SpaceheatName | ||
TypeName: Literal["go.dormant"] = "go.dormant" | ||
Version: Literal["000"] = "000" |
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,13 @@ | ||
"""Type wake.up, version 000""" | ||
|
||
from typing import Literal | ||
|
||
from pydantic import BaseModel | ||
|
||
from gwproto.property_format import SpaceheatName | ||
|
||
|
||
class WakeUp(BaseModel): | ||
ToName: SpaceheatName | ||
TypeName: Literal["wake.up"] = "wake.up" | ||
Version: Literal["000"] = "000" |
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,16 @@ | ||
""" | ||
Tests for enum admin.event.000 from the GridWorks Type Registry. | ||
""" | ||
|
||
from gwproto.enums import AdminEvent | ||
|
||
|
||
def test_admin_event() -> None: | ||
assert set(AdminEvent.values()) == { | ||
"WakeUp", | ||
"GoDormant", | ||
} | ||
|
||
assert AdminEvent.default() == AdminEvent.WakeUp | ||
assert AdminEvent.enum_name() == "admin.event" | ||
assert AdminEvent.enum_version() == "000" |
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,16 @@ | ||
""" | ||
Tests for enum admin.state.000 from the GridWorks Type Registry. | ||
""" | ||
|
||
from gwproto.enums import AdminState | ||
|
||
|
||
def test_admin_state() -> None: | ||
assert set(AdminState.values()) == { | ||
"Awake", | ||
"Dormant", | ||
} | ||
|
||
assert AdminState.default() == AdminState.Dormant | ||
assert AdminState.enum_name() == "admin.state" | ||
assert AdminState.enum_version() == "000" |
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
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,15 @@ | ||
"""Tests go.dormant type, version 000""" | ||
|
||
from gwproto.named_types import GoDormant | ||
|
||
|
||
def test_go_dormant_generated() -> None: | ||
d = { | ||
"ToName": "pico-cycler", | ||
"TypeName": "go.dormant", | ||
"Version": "000", | ||
} | ||
|
||
d2 = GoDormant.model_validate(d).model_dump(exclude_none=True) | ||
|
||
assert d2 == d |
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,15 @@ | ||
"""Tests wake.up type, version 000""" | ||
|
||
from gwproto.named_types import WakeUp | ||
|
||
|
||
def test_wake_up_generated() -> None: | ||
d = { | ||
"ToName": "pico-cycler", | ||
"TypeName": "wake.up", | ||
"Version": "000", | ||
} | ||
|
||
d2 = WakeUp.model_validate(d).model_dump(exclude_none=True) | ||
|
||
assert d2 == d |