Skip to content

Commit

Permalink
test: Migrate and reactivate old unittest for shelf loading
Browse files Browse the repository at this point in the history
Mark it as expexted to fail similar to the early return contained before.
  • Loading branch information
AiyionPrime authored and oroulet committed Feb 20, 2024
1 parent 26bf738 commit c7d4354
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Tests that can only be run on server side must be defined here
"""
import asyncio
import shelve
from pathlib import Path

import pytest
import logging
from datetime import timedelta
Expand Down Expand Up @@ -777,30 +780,24 @@ async def test_message_limits_works(restore_transport_limits_server: Server):
await n.read_value()


"""
class TestServerCaching(unittest.TestCase):
def runTest(self):
return # FIXME broken
tmpfile = NamedTemporaryFile()
path = tmpfile.name
tmpfile.close()
# create cache file
server = Server(shelffile=path)
# modify cache content
id = ua.NodeId(ua.ObjectIds.Server_ServerStatus_SecondsTillShutdown)
s = shelve.open(path, "w", writeback=True)
s[id.to_string()].attributes[ua.AttributeIds.Value].value = ua.DataValue(123)
s.close()
@pytest.mark.xfail(reason="FIXME broken", strict=True)
async def test_runTest(tmp_path: Path):
demo_shelf_file: Path = tmp_path / "some_shelf"

# ensure that we are actually loading from the cache
server = Server(shelffile=path)
assert server.get_node(id).read_value(), 123)
# create cache file
server = Server()
await server.init(shelf_file=demo_shelf_file)

os.remove(path)
# modify cache content
id = ua.NodeId(ua.ObjectIds.Server_ServerStatus_SecondsTillShutdown)
s = shelve.open(str(demo_shelf_file), "w", writeback=True)
s[id.to_string()].attributes[ua.AttributeIds.Value].value = ua.DataValue(123)
s.close()

"""
# ensure that we are actually loading from the cache
server = Server()
await server.init(shelf_file=demo_shelf_file)
assert await server.get_node(id).read_value() == 123


async def test_null_auth(server):
Expand Down

0 comments on commit c7d4354

Please sign in to comment.