def test_good_config_html_error_true(self, mock_dash, mock_flask): # No error, and dash starts. (html_error=True won't matter here.) args = self.demo_args() args.html_error = True app_runner.main(args) mock_flask.assert_called_once() mock_dash.assert_not_called()
def test_good_config_html_error_false(self, mock_dash, mock_flask): # No error, and dash starts. args = self.demo_args() args.html_error = False app_runner.main(args) mock_flask.assert_called_once() mock_dash.assert_not_called()
def test_bad_config_html_error_true(self, mock_dash, mock_flask): # Config has error, and the flask error server starts. args = self.demo_args() args.html_error = True args.demo = None # anything for a bad config app_runner.main(args) mock_dash.assert_not_called() mock_flask.assert_called_once()
def test_with_input(self, mock_init, mock_download): path = relative_path(__file__, '../../fixtures/good/input.json') refinery_args = app_runner_refinery.arg_parser().parse_args([ '--input', path]) runner_args = app_runner_refinery.RunnerArgs(refinery_args) app_runner.main(runner_args) mock_init.assert_called_once() mock_download.assert_called()
def test_bad_config_html_error_false(self, mock_dash, mock_flask): # Config has error, and it should not be caught. args = self.demo_args() args.html_error = False args.demo = None # anything for a bad config with self.assertRaisesRegex( Exception, r'Either "demo" or "files" is required' ): app_runner.main(args) mock_dash.assert_not_called() mock_flask.assert_not_called()
response.close() return files def arg_parser(): parser = argparse.ArgumentParser( description='Webapp for visualizing differential expression') parser.add_argument( '--input', type=str, required=True, # Because it's a "str" rather than "file", # does not require file to exist. help='If the specified file does not exist, ' 'falls back to environment variables: ' 'First, INPUT_JSON or INPUT_JSON_URL, ' 'and if neither of those exist, ' 'FILE_URLS, DIFF_URLS, META_URLS.') parser.add_argument('--port', type=int, default=80) # During development, it's useful to be able to specify a high port. return parser if __name__ == '__main__': args = RunnerArgs(arg_parser().parse_args()) print('args from {}: {}'.format(__name__, args)) assert args.files app_runner.main(args)
def test_demo_args(self, mock_flask): args = self.demo_args() app_runner.main(args) mock_flask.assert_called_once()