Beispiel #1
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")
Beispiel #2
0
 def _get(self):
     """ Loads the current state from persistence """
     return persistence.get(self._state_path())
Beispiel #3
0
	def test_get(self):
		self.assertEqual(None, persistence.get("keyname"))
Beispiel #4
0
	def test_failure(self):
		# should swallow errors when setting
		self.mock.get.side_effect = IOError("Failure")
		self.mock.set.side_effect = IOError("Failure")
		persistence.get("lights/fan")
		persistence.set("lights/fan", "value")
Beispiel #5
0
	def test_get_wrong_name(self):
		key = "key_name"
		data = "Test"
		persistence.set(key, data)
		self.assertEqual(None, persistence.get(key+"Wrong"))
Beispiel #6
0
	def test_get(self):
		self.mock.get.side_effect = lambda key:None
		self.assertEqual(None, persistence.get("keyname"))
		self.mock.get.assert_called_once_with("keyname")
Beispiel #7
0
	def test_save(self):
		key = "key_name"
		data = "Test"
		persistence.set(key, data)
		self.assertEqual(data, persistence.get(key))
Beispiel #8
0
	def test_empty(self):
		self.assertEqual(None, persistence.get('nonexistent'))