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)
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)
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()
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()
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)
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})