def test_manual_update(self): """ Test that the manual update actually updates the state in the cache """ path = '/foo' foo = 'foo' bar = 'bar' state = ApplicationState(application_host=foo, configuration_path=path) cache = self._create_app_state_cache() cache._cache.update({path: state.to_dictionary()}) self.zoo_keeper.get(self.configuration.override_node).AndReturn( ('{}', None)) self.zoo_keeper.set(self.configuration.override_node, '{"/foo": {"application_host": "bar"}}') self.zoo_keeper.get(self.configuration.override_node).AndReturn( ('{"/foo": {"application_host": "bar"}}', None)) self.time_estimate_cache.get_graphite_data('/foo/bar/head').AndReturn( {}) self.mox.ReplayAll() # test that the state's attribute actually changes cache.manual_update(path, 'application_host', bar) result = cache._get_existing_attribute(path, 'application_host') self.assertEqual(bar, result)
class TestApplicationState(TestCase): def setUp(self): self.state = ApplicationState(application_name="1", configuration_path="2", application_status="3", application_host=None, completion_time=1388556000, trigger_time="6", error_state="7", delete="8", local_mode="9", login_user="******", fqdn="11", last_command="12") def test_to_dictionary(self): self.assertEquals( { 'application_name': "1", 'configuration_path': "2", 'application_status': "unknown", 'application_host': "", 'completion_time': '2014-01-01 00:00:00', 'trigger_time': "6", 'error_state': "7", 'delete': "8", 'local_mode': "9", 'login_user': "******", 'fqdn': "11", 'last_command': "12" }, self.state.to_dictionary() )
class TestApplicationState(TestCase): def setUp(self): self.state = ApplicationState(application_name="1", configuration_path="2", application_status="3", application_host=None, last_update=1388556000, start_stop_time="6", error_state="7", delete="8", local_mode="9", login_user="******", last_command="12", pd_disabled=False, grayed=True, read_only=True, load_times=1, restart_count=0, platform=0) def test_to_dictionary(self): self.assertEquals( { 'application_name': "1", 'configuration_path': "2", 'application_status': "unknown", 'application_host': "", 'last_update': '2014-01-01 00:00:00', 'start_stop_time': "6", 'error_state': "7", 'delete': "8", 'local_mode': "9", 'login_user': "******", 'last_command': "12", 'pd_disabled': False, 'grayed': True, 'read_only': True, 'load_times': 1, 'restart_count': 0, 'platform': 0 }, self.state.to_dictionary() )
class TestApplicationState(TestCase): def setUp(self): self.state = ApplicationState( application_name="1", configuration_path="2", application_status="3", application_host=None, last_update=1388556000, start_stop_time="6", error_state="7", delete="8", local_mode="9", login_user="******", last_command="12", pd_disabled=False, grayed=True, read_only=True, platform=0, ) def test_to_dictionary(self): self.assertEquals( { "application_name": "1", "configuration_path": "2", "application_status": "unknown", "application_host": "", "last_update": "2014-01-01 00:00:00", "start_stop_time": "6", "error_state": "7", "delete": "8", "local_mode": "9", "login_user": "******", "last_command": "12", "pd_disabled": False, "grayed": True, "read_only": True, "platform": 0, }, self.state.to_dictionary(), )
def test_manual_update(self): """ Test that the manual update actually updates the state in the cache """ path = '/foo' foo = 'foo' bar = 'bar' state = ApplicationState(application_host=foo, configuration_path=path) cache = self._create_app_state_cache() cache._cache.update({path: state.to_dictionary()}) self.zoo_keeper.get(self.configuration.override_node).AndReturn(('{}', None)) self.zoo_keeper.set(self.configuration.override_node, '{"application_host": {"/foo": "bar"}}') self.zoo_keeper.get(self.configuration.override_node).AndReturn(('{"application_host": {"/foo": "bar"}}', None)) self.mox.ReplayAll() # test that the state's attribute actually changes cache.manual_update(path, 'application_host', bar) result = cache._get_existing_attribute(path, 'application_host') self.assertEqual(bar, result)
def test_get_existing_attribute(self): """ Test pulling values from existing application states """ path = '/foo' host = 'FOOHOST' default_val = 'default_val' state = ApplicationState(application_host=host, configuration_path=path) cache = self._create_app_state_cache() cache._cache.update({path: state.to_dictionary()}) # test return of existing attribute result = cache._get_existing_attribute(path, 'application_host') self.assertEqual(host, result) # state exists, attribute does not result = cache._get_existing_attribute(path, 'foo', default=default_val) self.assertEqual(default_val, result) # state does not exist result = cache._get_existing_attribute('', 'application_host') self.assertEqual(False, result)
def test_get_existing_attribute(self): """ Test pulling values from existing application states """ path = '/foo' host = 'FOOHOST' default_val = 'default_val' state = ApplicationState(application_host=host, configuration_path=path) cache = self._create_app_state_cache() cache._cache.update({path: state.to_dictionary()}) # test return of existing attribute result = cache._get_existing_attribute(path, 'application_host') self.assertEqual(host, result) # state exists, attribute does not result = cache._get_existing_attribute(path, 'foo') self.assertEqual(None, result) # state does not exist result = cache._get_existing_attribute('', 'application_host') self.assertEqual(None, result)