generated from mochi-hpc/margo-microservice-template
-
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
Showing
5 changed files
with
79 additions
and
10 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
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,53 @@ | ||
import unittest | ||
import json | ||
import mochi.flock.client as mfc | ||
import mochi.flock.server as mfs | ||
from mochi.flock.view import GroupView | ||
import pymargo.core | ||
|
||
class TestClient(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.engine = pymargo.core.Engine("na+sm", pymargo.core.server) | ||
self.address = str(self.engine.address) | ||
config = { | ||
"group": { | ||
"type": "static", | ||
"config": {} | ||
} | ||
} | ||
self.initial_view = GroupView() | ||
for i in range(0, 5): | ||
self.initial_view.members.add(self.address, i) | ||
self.initial_view.metadata.add("mykey", "myvalue") | ||
self.providers = [] | ||
for i in range(0, 5): | ||
self.providers.append( | ||
mfs.Provider(self.engine, i, json.dumps(config), self.initial_view.copy())) | ||
self.client = mfc.Client(self.engine) | ||
|
||
def tearDown(self): | ||
del self.client | ||
del self.providers | ||
self.engine.finalize() | ||
del self.engine | ||
|
||
def test_view(self): | ||
gh = self.client.make_group_handle(self.address, 3) | ||
gh.update() | ||
view = gh.view | ||
self.assertIsInstance(view, GroupView) | ||
self.assertEqual(len(view.members), 5) | ||
for i in range(0, 5): | ||
self.assertEqual(view.members[i].address, self.address) | ||
self.assertEqual(view.members[i].provider_id, i) | ||
self.assertEqual(view.metadata["mykey"], "myvalue") | ||
print(view) | ||
|
||
def test_update(self): | ||
gh = self.client.make_group_handle(self.address, 3) | ||
gh.update() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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