def test_parameters_validation(self): with self.subTest('not a size'): with self.assertRaises(ValueError): LivyHook.build_post_batch_body(file='appname', executor_memory='xxx') with self.subTest('list of stringables'): self.assertEqual( LivyHook.build_post_batch_body(file='appname', args=['a', 1, 0.1])['args'], ['a', '1', '0.1'])
def test_build_body(self): with self.subTest('minimal request'): body = LivyHook.build_post_batch_body(file='appname') self.assertEqual(body, {'file': 'appname'}) with self.subTest('complex request'): body = LivyHook.build_post_batch_body( file='appname', class_name='org.example.livy', proxy_user='******', args=['a', '1'], jars=['jar1', 'jar2'], files=['file1', 'file2'], py_files=['py1', 'py2'], archives=['arch1', 'arch2'], queue='queue', name='name', conf={'a': 'b'}, driver_cores=2, driver_memory='1M', executor_memory='1m', executor_cores='1', # noqa num_executors='10', ) self.assertEqual( body, { 'file': 'appname', 'className': 'org.example.livy', 'proxyUser': '******', 'args': ['a', '1'], 'jars': ['jar1', 'jar2'], 'files': ['file1', 'file2'], 'pyFiles': ['py1', 'py2'], 'archives': ['arch1', 'arch2'], 'queue': 'queue', 'name': 'name', 'conf': { 'a': 'b' }, 'driverCores': 2, 'driverMemory': '1M', 'executorMemory': '1m', 'executorCores': '1', 'numExecutors': '10', }, )