Skip to content

Commit

Permalink
added python tests for provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorier committed Jun 10, 2024
1 parent 3fd77d7 commit 523802c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/mochi/flock/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class Provider:

def __init__(self, engine: pymargo.core.Engine, provider_id: int, config: str, initial_view: GroupView):
self._internal = pyflock_server.Provider(
self._engine.get_internal_mid(), provider_id, config, initial_view)
engine.get_internal_mid(), provider_id, config, initial_view)
1 change: 1 addition & 0 deletions python/mochi/flock/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import mochi.flock.client as mfc
from pymargo.core import Engine


class TestClient(unittest.TestCase):

def test_init_client_from_address(self):
Expand Down
26 changes: 26 additions & 0 deletions python/mochi/flock/test_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import unittest
import json
import mochi.flock.server as mfs
import mochi.flock.view as view
import pymargo.core

class TestClient(unittest.TestCase):

def test_init_provider(self):
with pymargo.core.Engine("na+sm", pymargo.core.server) as engine:
address = str(engine.address)
config = {
"group": {
"type": "static",
"config": {}
}
}
initial_view = view.GroupView()
initial_view.members.add(address, 42)
provider = mfs.Provider(engine, 42, json.dumps(config), initial_view)
del provider
engine.finalize()


if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion python/src/py-flock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef py11::capsule pyhg_addr_t;
#define MID2CAPSULE(__mid) py11::capsule((void*)(__mid), "margo_instance_id")
#define CAPSULE2MID(__caps) (margo_instance_id)(__caps)

PYBIND11_MODULE(pybedrock_server, m) {
PYBIND11_MODULE(pyflock_server, m) {
m.doc() = "Flock server python extension";

py11::class_<flock::Provider>(m, "Provider")
Expand Down

0 comments on commit 523802c

Please sign in to comment.