Skip to content

Commit

Permalink
Add boilerplate code for GET requests
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanscherzinger committed Jul 9, 2024
1 parent 95d8ab2 commit 07b69ab
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
16 changes: 13 additions & 3 deletions schunk_egu_egk_dummy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ async def put(msg: Message):
return True


@server.get("/")
async def get():
return "Dummy ready"
@server.get("/adi/info.json")
async def get_info():
return dummy.get_info()


@server.get("/adi/enum.json")
async def get_enum():
return dummy.get_enum()


@server.get("/adi/data.json")
async def get_data():
return dummy.get_data()
9 changes: 9 additions & 0 deletions schunk_egu_egk_dummy/src/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ def _run(self):
def process(self, msg: str) -> bool:
print(msg)
return True

def get_info(self) -> dict:
return {"dataformat": 0, "numadis": 123, "webversion": 1}

def get_enum(self) -> list:
return []

def get_data(self) -> list:
return []
16 changes: 16 additions & 0 deletions schunk_egu_egk_dummy/tests/test_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,19 @@ def test_dummy_processes_messages():
dummy = Dummy()
msg = "Hello simulator!"
assert dummy.process(msg)


def test_dummy_returns_valid_info():
dummy = Dummy()
info = {"dataformat": 0, "numadis": 123, "webversion": 1}
assert dummy.get_info() == info


def test_dummy_returns_valid_enums():
dummy = Dummy()
assert dummy.get_enum() == []


def test_dummy_returns_valid_data():
dummy = Dummy()
assert dummy.get_data() == []

0 comments on commit 07b69ab

Please sign in to comment.