Exemple #1
0
 def test_basic(self, autojoin):
     zk = create_mock(["Party"])
     # Call
     p = ZkParty(zk, "path", "id", "autojoin")
     # Tests
     ntools.eq_(p._autojoin, "autojoin")
     ntools.eq_(p._path, "path")
     zk.Party.assert_called_once_with("path", "id")
     ntools.eq_(p._party, zk.Party.return_value)
     autojoin.assert_called_once_with(p)
Exemple #2
0
 def test_noauto(self, init, list_):
     p = ZkParty("zk", "path", "id", "autojoin")
     p._autojoin = False
     p.join = create_mock()
     p._path = "path"
     # Call
     p.autojoin()
     # Tests
     ntools.assert_false(p.join.called)
Exemple #3
0
 def test_auto(self, init, list_):
     p = ZkParty("zk", "path", "id", "autojoin")
     p._autojoin = True
     p.join = create_mock()
     p._path = "path"
     # Call
     p.autojoin()
     # Tests
     p.join.assert_called_once_with()
Exemple #4
0
 def test_basic(self, init):
     p = ZkParty("zk", "path", "id", "autojoin")
     p._party = create_mock(["join"])
     p.list = create_mock()
     # Call
     p.join()
     # Tests
     p._party.join.assert_called_once_with()
Exemple #5
0
 def _check_error(self, excp, init):
     p = ZkParty("zk", "path", "id", "autojoin")
     p._party = create_mock(["__iter__"])
     p._party.__iter__.side_effect = excp
     # Call
     ntools.assert_raises(ZkNoConnection, p.list)
Exemple #6
0
 def test_basic(self, init):
     p = ZkParty("zk", "path", "id", "autojoin")
     p._party = MagicMock(spec_set=["__iter__"])
     p._party.__iter__.return_value = [1, 2, 3]
     # Call
     ntools.eq_(p.list(), {1, 2, 3})