def _do_render(build_directory_path: str, www_directory_path: str) -> None: # Use a shell on Windows so subprocess can find the executables it needs (see https://bugs.python.org/issue17023). shell = sys.platform.startswith('win32') # Install third-party dependencies. subprocess.run(['npm', 'install', '--production'], cwd=build_directory_path, shell=shell) shutil.copy2(path.join(build_directory_path, 'node_modules', 'redoc', 'bundles', 'redoc.standalone.js'), path.join(www_directory_path, 'redoc.js')) logging.getLogger().info('Built the ReDoc API documentation.')
def _do_render(build_directory_path: str, www_directory_path: str) -> None: # Install third-party dependencies. subprocess.run(['npm', 'install', '--production'], cwd=build_directory_path) # Run Webpack. subprocess.run(['npm', 'run', 'webpack'], cwd=build_directory_path) output_directory_path = path.join(path.dirname(build_directory_path), 'output') shutil.copy2(path.join(output_directory_path, 'trees.css'), path.join(www_directory_path, 'trees.css')) shutil.copy2(path.join(output_directory_path, 'trees.js'), path.join(www_directory_path, 'trees.js')) logging.getLogger().info('Built the interactive family trees.')
def _do_render(build_directory_path: str, www_directory_path: str) -> None: # Use a shell on Windows so subprocess can find the executables it needs (see https://bugs.python.org/issue17023). shell = sys.platform.startswith('win32') # Install third-party dependencies. subprocess.run(['npm', 'install', '--production'], cwd=build_directory_path, shell=shell) # Run Webpack. subprocess.run(['npm', 'run', 'webpack'], cwd=build_directory_path, shell=shell) output_directory_path = path.join(path.dirname(build_directory_path), 'output') shutil.copy2(path.join(output_directory_path, 'trees.css'), path.join(www_directory_path, 'trees.css')) shutil.copy2(path.join(output_directory_path, 'trees.js'), path.join(www_directory_path, 'trees.js')) logging.getLogger().info('Built the interactive family trees.')
def test_readme_should_contain_cli_help(self): with TemporaryDirectory() as betty_site_path: configuration = { 'base_url': 'https://example.com', 'output': path.join(betty_site_path, 'output'), } with open(path.join(betty_site_path, 'betty.json'), 'w') as f: json.dump(configuration, f) with os.ChDir(betty_site_path): expected = subprocess.run(['betty', '--help']).stdout with open('README.md') as f: actual = f.read().encode() self.assertIn(expected, actual)
def test_readme_should_contain_cli_help(self): with TemporaryDirectory() as working_directory_path_str: working_directory_path = Path(working_directory_path_str) configuration = { 'base_url': 'https://example.com', 'output': str(working_directory_path / 'output'), } with open(working_directory_path / 'betty.json', 'w') as f: json.dump(configuration, f) with os.ChDir(working_directory_path): expected = subprocess.run(['betty', '--help'], universal_newlines=True).stdout with open('README.md') as f: actual = f.read() self.assertIn(expected, actual)
def test_without_errors(self): process = subprocess.run(['true']) self.assertIsInstance(process, CompletedProcess)
def test_with_errors(self): with self.assertRaises(CalledProcessError): subprocess.run(['false'])