def test_watch(self): ''' Test if watch returns the right tuples ''' with patch.dict(etcd_mod.__utils__, {'etcd_util.get_conn': self.EtcdClientMock}): self.instance.watch.return_value = { 'value': 'stack', 'changed': True, 'dir': False, 'mIndex': 1, 'key': '/salt' } self.assertEqual(etcd_mod.watch('/salt'), self.instance.watch.return_value) self.instance.watch.assert_called_with('/salt', recurse=False, timeout=0, index=None) self.instance.watch.return_value['dir'] = True self.assertEqual( etcd_mod.watch('/some-dir', recurse=True, timeout=5, index=10), self.instance.watch.return_value) self.instance.watch.assert_called_with('/some-dir', recurse=True, timeout=5, index=10) self.assertEqual(etcd_mod.watch('/some-dir', True, None, 5, 10), self.instance.watch.return_value) self.instance.watch.assert_called_with('/some-dir', recurse=True, timeout=5, index=10)
def test_watch(etcd_client_mock, instance): """ Test if watch returns the right tuples """ with patch.dict(etcd_mod.__utils__, {"etcd_util.get_conn": etcd_client_mock}): instance.watch.return_value = { "value": "stack", "changed": True, "dir": False, "mIndex": 1, "key": "/salt", } assert etcd_mod.watch("/salt") == instance.watch.return_value instance.watch.assert_called_with("/salt", recurse=False, timeout=0, index=None) instance.watch.return_value["dir"] = True assert (etcd_mod.watch("/some-dir", recurse=True, timeout=5, index=10) == instance.watch.return_value) instance.watch.assert_called_with("/some-dir", recurse=True, timeout=5, index=10) assert (etcd_mod.watch("/some-dir", True, None, 5, 10) == instance.watch.return_value) instance.watch.assert_called_with("/some-dir", recurse=True, timeout=5, index=10)
def test_watch(self): """ Test if watch returns the right tuples """ with patch.dict( etcd_mod.__utils__, {"etcd_util.get_conn": self.EtcdClientMock} ): self.instance.watch.return_value = { "value": "stack", "changed": True, "dir": False, "mIndex": 1, "key": "/salt", } self.assertEqual(etcd_mod.watch("/salt"), self.instance.watch.return_value) self.instance.watch.assert_called_with( "/salt", recurse=False, timeout=0, index=None ) self.instance.watch.return_value["dir"] = True self.assertEqual( etcd_mod.watch("/some-dir", recurse=True, timeout=5, index=10), self.instance.watch.return_value, ) self.instance.watch.assert_called_with( "/some-dir", recurse=True, timeout=5, index=10 ) self.assertEqual( etcd_mod.watch("/some-dir", True, None, 5, 10), self.instance.watch.return_value, ) self.instance.watch.assert_called_with( "/some-dir", recurse=True, timeout=5, index=10 )
def test_with_missing_profile(subtests, prefix, etcd_version, etcd_port): """ Test the correct response when the profile is missing and we can't connect """ if etcd_version in (EtcdVersion.v2, EtcdVersion.v3_v2_mode) and etcd_port != 2379: # Only need to run this once with subtests.test("Test no profile and bad connection in get_"): assert etcd_mod.get_("{}/1".format(prefix)) is None with subtests.test("Test no profile and bad connection in set_"): assert etcd_mod.set_("{}/1".format(prefix), "lol") is None with subtests.test("Test no profile and bad connection in update"): assert etcd_mod.update({"{}/1".format(prefix): "SIUUU"}) is None with subtests.test("Test no profile and bad connection in watch"): assert etcd_mod.watch("{}/1".format(prefix)) is None with subtests.test("Test no profile and bad connection in ls_"): assert etcd_mod.ls_() is None with subtests.test("Test no profile and bad connection in rm"): assert etcd_mod.rm_("{}/1".format(prefix)) is None with subtests.test("Test no profile and bad connection in tree"): assert etcd_mod.tree() is None
def test_watch(self): ''' Test if watch returns the right tuples ''' with patch.dict(etcd_mod.__utils__, {'etcd_util.get_conn': self.EtcdClientMock}): self.instance.watch.return_value = { 'value': 'stack', 'changed': True, 'dir': False, 'mIndex': 1, 'key': '/salt' } self.assertEqual(etcd_mod.watch('/salt'), self.instance.watch.return_value) self.instance.watch.assert_called_with('/salt', recurse=False, timeout=0, index=None) self.instance.watch.return_value['dir'] = True self.assertEqual(etcd_mod.watch('/some-dir', recurse=True, timeout=5, index=10), self.instance.watch.return_value) self.instance.watch.assert_called_with('/some-dir', recurse=True, timeout=5, index=10) self.assertEqual(etcd_mod.watch('/some-dir', True, None, 5, 10), self.instance.watch.return_value) self.instance.watch.assert_called_with('/some-dir', recurse=True, timeout=5, index=10)
def wait_func(return_list): return_list.append( etcd_mod.watch("{}/1".format(prefix), timeout=30, profile=profile_name) )