code
stringlengths
3
6.57k
GuestAgent(path=self.agent_path)
self.assertFalse(agent.is_blacklisted)
agent._unpack()
self.assertFalse(agent.is_blacklisted)
self.assertEqual(agent.is_blacklisted, agent.error.is_blacklisted)
agent.mark_failure(is_fatal=True)
self.assertTrue(agent.is_blacklisted)
self.assertEqual(agent.is_blacklisted, agent.error.is_blacklisted)
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_resource_gone_error_not_blacklisted(self, mock_loaded, mock_downloaded)
ResourceGoneError()
GuestAgent(path=self.agent_path)
self.assertFalse(agent.is_blacklisted)
self.fail("Exception was not expected!")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_ioerror_not_blacklisted(self, mock_loaded, mock_downloaded)
IOError()
GuestAgent(path=self.agent_path)
self.assertFalse(agent.is_blacklisted)
self.fail("Exception was not expected!")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_is_downloaded(self, mock_loaded, mock_downloaded)
GuestAgent(path=self.agent_path)
self.assertFalse(agent.is_downloaded)
agent._unpack()
self.assertTrue(agent.is_downloaded)
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_mark_failure(self, mock_loaded, mock_downloaded)
GuestAgent(path=self.agent_path)
agent.mark_failure()
self.assertEqual(1, agent.error.failure_count)
agent.mark_failure(is_fatal=True)
self.assertEqual(2, agent.error.failure_count)
self.assertTrue(agent.is_blacklisted)
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_unpack(self, mock_loaded, mock_downloaded)
GuestAgent(path=self.agent_path)
self.assertFalse(os.path.isdir(agent.get_agent_dir()
agent._unpack()
self.assertTrue(os.path.isdir(agent.get_agent_dir()
self.assertTrue(os.path.isfile(agent.get_agent_manifest_path()
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_unpack_fail(self, mock_loaded, mock_downloaded)
GuestAgent(path=self.agent_path)
self.assertFalse(os.path.isdir(agent.get_agent_dir()
os.remove(agent.get_agent_pkg_path()
self.assertRaises(UpdateError, agent._unpack)
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_load_manifest(self, mock_loaded, mock_downloaded)
GuestAgent(path=self.agent_path)
agent._unpack()
agent._load_manifest()
self.assertEqual(agent.manifest.get_enable_command()
agent.get_agent_cmd()
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_load_manifest_missing(self, mock_loaded, mock_downloaded)
GuestAgent(path=self.agent_path)
self.assertFalse(os.path.isdir(agent.get_agent_dir()
agent._unpack()
os.remove(agent.get_agent_manifest_path()
self.assertRaises(UpdateError, agent._load_manifest)
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_load_manifest_is_empty(self, mock_loaded, mock_downloaded)
GuestAgent(path=self.agent_path)
self.assertFalse(os.path.isdir(agent.get_agent_dir()
agent._unpack()
self.assertTrue(os.path.isfile(agent.get_agent_manifest_path()
open(agent.get_agent_manifest_path()
json.dump(EMPTY_MANIFEST, file)
self.assertRaises(UpdateError, agent._load_manifest)
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
test_load_manifest_is_malformed(self, mock_loaded, mock_downloaded)
GuestAgent(path=self.agent_path)
self.assertFalse(os.path.isdir(agent.get_agent_dir()
agent._unpack()
self.assertTrue(os.path.isfile(agent.get_agent_manifest_path()
open(agent.get_agent_manifest_path()
file.write("This is not JSON data")
self.assertRaises(UpdateError, agent._load_manifest)
test_load_error(self)
GuestAgent(path=self.agent_path)
agent._load_error()
self.assertTrue(agent.error is not None)
patch("azurelinuxagent.ga.update.GuestAgent._ensure_downloaded")
patch("azurelinuxagent.ga.update.GuestAgent._ensure_loaded")
patch("azurelinuxagent.ga.update.restutil.http_get")
test_download(self, mock_http_get, mock_loaded, mock_downloaded)
self.remove_agents()
self.assertFalse(os.path.isdir(self.agent_path)
load_bin_data(self._get_agent_file_name()