Example #1
0
 def test_host_envvar(self):
     os.environ['HOST'] = 'server.company.com'
     app = myapp.create_application()
     self.assertEqual(app.config['HOST'], 'server.company.com')
     with app.test_request_context('/'):
         self.assertEqual(flask.current_app.config['HOST'],
                          'server.company.com')
 def test_run_keywords_override_defaults(self, flask_run):
     inst = myapp.create_application()
     inst.run(debug=True, host='127.0.0.1', port=6543)
     flask_run.assert_called_with(inst,
                                  host='127.0.0.1',
                                  port=6543,
                                  debug=True)
 def test_host_envvar(self):
     os.environ['HOST'] = 'server.company.com'
     app = myapp.create_application()
     self.assertEqual(app.config['HOST'], 'server.company.com')
     with app.test_request_context('/'):
         self.assertEqual(flask.current_app.config['HOST'],
                 'server.company.com')
Example #4
0
 def test_debug_flag_from_environment(self):
     os.environ['DEBUG'] = 'true'
     app = myapp.create_application()
     self.assertEqual(app.config['DEBUG'], True)
     self.assertEqual(app.debug, True)
     with app.test_request_context('/'):
         self.assertEqual(flask.current_app.config['DEBUG'], True)
         self.assertEqual(flask.current_app.debug, True)
 def test_environment_args(self, flask_run):
     os.environ['HOST'] = 'server.company.com'
     os.environ['PORT'] = '6543'
     os.environ['DEBUG'] = 'True'
     app = myapp.create_application()
     app.run()
     flask_run.assert_called_once_with(app, host='server.company.com',
             port=6543, debug=True)
 def test_debug_flag_from_environment(self):
     os.environ['DEBUG'] = 'true'
     app = myapp.create_application()
     self.assertEqual(app.config['DEBUG'], True)
     self.assertEqual(app.debug, True)
     with app.test_request_context('/'):
         self.assertEqual(flask.current_app.config['DEBUG'], True)
         self.assertEqual(flask.current_app.debug, True)
 def test_run_curries_arguments(self, flask_run):
     inst = myapp.create_application()
     inst.run()
     flask_run.assert_called_with(inst, host='0.0.0.0', port=5000,
             debug=False)
     inst.run(42, foo='bar')
     flask_run.assert_called_with(inst, 42, host='0.0.0.0', port=5000,
             debug=False, foo='bar')
Example #8
0
 def test_environment_args(self, flask_run):
     os.environ['HOST'] = 'server.company.com'
     os.environ['PORT'] = '6543'
     os.environ['DEBUG'] = 'True'
     app = myapp.create_application()
     app.run()
     flask_run.assert_called_once_with(app,
                                       host='server.company.com',
                                       port=6543,
                                       debug=True)
 def test_create_application_curries_arguments(self, app_class):
     myapp.create_application()
     app_class.assert_called_with()
     myapp.create_application(1, 2, 3)
     app_class.assert_called_with(1, 2, 3)
     myapp.create_application(1, 2, three=3)
     app_class.assert_called_with(1, 2, three=3)
 def test_create_application_curries_arguments(self, app_class):
     myapp.create_application()
     app_class.assert_called_with()
     myapp.create_application(1, 2, 3)
     app_class.assert_called_with(1,2,3)
     myapp.create_application(1, 2, three=3)
     app_class.assert_called_with(1, 2, three=3)
 def test_run_curries_arguments(self, flask_run):
     inst = myapp.create_application()
     inst.run()
     flask_run.assert_called_with(inst,
                                  host='0.0.0.0',
                                  port=5000,
                                  debug=False)
     inst.run(42, foo='bar')
     flask_run.assert_called_with(inst,
                                  42,
                                  host='0.0.0.0',
                                  port=5000,
                                  debug=False,
                                  foo='bar')
 def test_port_defaults_to_5000(self):
     app = myapp.create_application()
     self.assertEqual(app.config['PORT'], 5000)
 def test_port_defaults_to_5000(self):
     app = myapp.create_application()
     self.assertEqual(app.config['PORT'], 5000)
Example #14
0
 def test_port_envvar(self):
     os.environ['PORT'] = '6543'
     app = myapp.create_application()
     self.assertEqual(app.config['PORT'], 6543)
     with app.test_request_context('/'):
         self.assertEqual(flask.current_app.config['PORT'], 6543)
 def test_debug_defaults_to_false(self):
     app = myapp.create_application()
     self.assertEqual(app.config['DEBUG'], False)
     self.assertEqual(app.debug, False)
 def test_host_defaults_to_all(self):
     app = myapp.create_application()
     self.assertEqual(app.config['HOST'], '0.0.0.0')
 def test_config_file_from_envvar_is_read(self, from_envvar):
     inst = myapp.create_application()
     from_envvar.assert_called_with('APP_CONFIG', silent=True)
     inst = myapp.create_application(config_envvar='CUSTOM_NAME')
     from_envvar.assert_called_with('CUSTOM_NAME', silent=True)
 def test_secret_key_is_generated(self):
     app = myapp.create_application()
     key = app.config['SECRET_KEY']
     self.assertIsNotNone(key)
     self.assertEqual(len(key), 24)
 def test_secret_key_is_generated(self):
     app = myapp.create_application()
     key = app.config['SECRET_KEY']
     self.assertIsNotNone(key)
     self.assertEqual(len(key), 24)
 def test_debug_defaults_to_false(self):
     app = myapp.create_application()
     self.assertEqual(app.config['DEBUG'], False)
     self.assertEqual(app.debug, False)
 def test_port_envvar(self):
     os.environ['PORT'] = '6543'
     app = myapp.create_application()
     self.assertEqual(app.config['PORT'], 6543)
     with app.test_request_context('/'):
         self.assertEqual(flask.current_app.config['PORT'], 6543)
 def test_host_defaults_to_all(self):
     app = myapp.create_application()
     self.assertEqual(app.config['HOST'], '0.0.0.0')
 def test_config_file_from_envvar_is_read(self, from_envvar):
     inst = myapp.create_application()
     from_envvar.assert_called_with('APP_CONFIG', silent=True)
     inst = myapp.create_application(config_envvar='CUSTOM_NAME')
     from_envvar.assert_called_with('CUSTOM_NAME', silent=True)
 def test_run_keywords_override_defaults(self, flask_run):
     inst = myapp.create_application()
     inst.run(debug=True, host='127.0.0.1', port=6543)
     flask_run.assert_called_with(inst, host='127.0.0.1', port=6543,
             debug=True)