def jobs(self, jobid=None, stop=False): if not jobid: resp = HadoopHandler().list_jobs() else: resp = HadoopHandler().kill_job(jobid) return resp
class TestHadoopHandler(unittest.TestCase): """ Tests for the hadoop interaction class """ def setUp(self): os.environ['espa_api_testing'] = 'True' self.hadoop = HadoopHandler() def tearDown(self): os.environ['espa_api_testing'] = '' @patch('api.external.hadoop.HadoopHandler._remote_cmd', mockhadoop.list_jobs) def test_list_jobs(self): resp = self.hadoop.list_jobs() self.assertIsInstance(resp, dict) for key, value in resp.items(): self.assertIsInstance(key, str) self.assertIsInstance(value, str) @patch('api.external.hadoop.HadoopHandler.job_names_ids', mockhadoop.jobs_names_ids) def test_job_names_ids(self): resp = self.hadoop.job_names_ids() self.assertIsInstance(resp, dict) @patch('api.external.hadoop.HadoopHandler._remote_cmd', mockhadoop.slave_ips) def test_slave_ips(self): resp = self.hadoop.slave_ips() self.assertIsInstance(resp, list) self.assertTrue(len(resp) > 0) @patch('api.external.hadoop.HadoopHandler.master_ip', mockhadoop.master_ip) def test_master_ip(self): resp = self.hadoop.master_ip() self.assertIsInstance(resp, str) self.assertTrue(len(resp.split('.')) == 4)
class TestHadoopHandler(unittest.TestCase): """ Tests for the hadoop interaction class """ def setUp(self): self.hadoop = HadoopHandler() def test_list_jobs(self): resp = self.hadoop.list_jobs() self.assertTrue('stdout' in resp.keys()) def test_job_names_ids(self): resp = self.hadoop.job_names_ids() self.assertTrue(isinstance(resp, dict)) def test_slave_ips(self): resp = self.hadoop.slave_ips() self.assertTrue(isinstance(resp, list)) self.assertTrue(len(resp) > 0) def test_master_ip(self): resp = self.hadoop.master_ip() self.assertTrue(isinstance(resp, str)) self.assertTrue(len(resp.split('.')) == 4)
def setUp(self): os.environ['espa_api_testing'] = 'True' self.hadoop = HadoopHandler()
def setUp(self): self.hadoop = HadoopHandler()