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")
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()
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")
def setUp(self): self.mock = mock.Mock() settings = { "client": self.mock } config.PERSISTENCE = [persistence.Redis(**settings)]