示例#1
0
	def test_prefix_slash(self):
		settings = {
			"client": self.mock,
			"prefix": "/testname/"
		}
		config.PERSISTENCE = [persistence.Redis(**settings)]
		persistence.set("lights/fan", "value")
		self.mock.set.assert_called_once_with("/testname/lights/fan", "value")
		self.mock.publish.assert_called_once_with("/testname/lights/fan", "value")
示例#2
0
	def test_set_no_publish(self):
		settings = {
			"client": self.mock,
			"publish": False,
		}
		config.PERSISTENCE = [persistence.Redis(**settings)]
		persistence.set("lights/fan", "value")
		self.mock.set.assert_called_once_with("lights/fan", "value")
		self.mock.publish.assert_not_called()
示例#3
0
	def test_set_only_publish(self):
		settings = {
			"client": self.mock,
			"db": None,
		}
		config.PERSISTENCE = [persistence.Redis(**settings)]
		persistence.set("lights/fan", "value")
		self.assertEqual(None, persistence.get("lights/fan"))
		self.mock.set.assert_not_called()
		self.mock.get.assert_not_called()
		self.mock.publish.assert_called_once_with("lights/fan", "value")
示例#4
0
	def setUp(self):
		self.mock = mock.Mock()
		settings = {
			"client": self.mock
		}
		config.PERSISTENCE = [persistence.Redis(**settings)]