def test_create_agent_package(self):
     cli_options = {
         '--config': CONFIG_FILE,
         '--force': True,
         '--dryrun': False,
         '--no-validation': False,
         '--verbose': True
     }
     required_modules = [
         'cloudify-plugins-common', 'cloudify-rest-client',
         'cloudify-fabric-plugin', 'cloudify-agent', 'pyyaml', 'xmltodict'
     ]
     excluded_modules = [
         'cloudify-diamond-plugin', 'cloudify-script-plugin'
     ]
     config = ap._import_config(CONFIG_FILE)
     cli._run(cli_options)
     if os.path.isdir(TEST_VENV):
         shutil.rmtree(TEST_VENV)
     os.makedirs(TEST_VENV)
     utils.run('tar -xzvf {0} -C {1} --strip-components=1'.format(
         config['output_tar'], BASE_DIR))
     os.remove(config['output_tar'])
     self.assertTrue(os.path.isdir(TEST_VENV))
     pip_freeze_output = utils.get_installed(TEST_VENV).lower()
     for required_module in required_modules:
         self.assertIn(required_module, pip_freeze_output)
     for excluded_module in excluded_modules:
         self.assertNotIn(excluded_module, pip_freeze_output)
     shutil.rmtree(TEST_VENV)
 def test_create_agent_package(self):
     config = ap._import_config(CONFIG_FILE)
     ap.create(None, CONFIG_FILE, force=True, verbose=True)
     if os.path.isdir(config['venv']):
         raise Exception('venv exists before extracting agent.')
     os.makedirs(config['venv'])
     utils.run('tar -xzvf {0} -C {1} --strip-components=2'.format(
         config['output_tar'], BASE_DIR))
     os.remove(config['output_tar'])
     self.assertTrue(os.path.isdir(config['venv']))
     p = utils.run('{0}/bin/pip freeze'.format(config['venv']))
     self.assertIn('cloudify-plugins-common', p.stdout)
     self.assertIn('cloudify-rest-client', p.stdout)
     self.assertIn('cloudify-script-plugin', p.stdout)
     self.assertNotIn('cloudify-diamond-plugin', p.stdout)
     shutil.rmtree(config['venv'])
 def test_create_agent_package(self):
     cli_options = {
         '--config': CONFIG_FILE,
         '--force': True,
         '--dryrun': False,
         '--no-validation': False,
         '--verbose': True
     }
     required_modules = [
         'cloudify-plugins-common',
         'cloudify-rest-client',
         'cloudify-fabric-plugin',
         'cloudify-agent',
         'pyyaml',
         'xmltodict'
     ]
     excluded_modules = [
         'cloudify-diamond-plugin',
         'cloudify-script-plugin'
     ]
     config = ap._import_config(CONFIG_FILE)
     cli._run(cli_options)
     if os.path.isdir(TEST_VENV):
         shutil.rmtree(TEST_VENV)
     os.makedirs(TEST_VENV)
     utils.run('tar -xzvf {0} -C {1} --strip-components=1'.format(
         config['output_tar'], BASE_DIR))
     os.remove(config['output_tar'])
     self.assertTrue(os.path.isdir(TEST_VENV))
     pip_freeze_output = utils.get_installed(
         TEST_VENV).lower()
     for required_module in required_modules:
         self.assertIn(required_module, pip_freeze_output)
     for excluded_module in excluded_modules:
         self.assertNotIn(excluded_module, pip_freeze_output)
     shutil.rmtree(TEST_VENV)
 def test_run_bad_command(self):
     p = utils.run('suname')
     self.assertEqual(127, p.returncode)
 def test_run(self):
     p = utils.run('uname')
     self.assertEqual(0, p.returncode)
 def test_run_bad_command(self):
     p = utils.run('suname')
     self.assertEqual(127, p.returncode)
 def test_run(self):
     p = utils.run('uname')
     self.assertEqual(0, p.returncode)
 def test_install_module(self):
     utils.install_module(TEST_MODULE, TEST_VENV)
     p = utils.run('{0}/bin/pip freeze'.format(TEST_VENV))
     self.assertIn(TEST_MODULE, p.stdout)