示例#1
0
 def test_logout_redirect(self):
     tester = app.test_client(self)
     response = tester.get('/logout',
                           content_type='html/text',
                           follow_redirects=True)
     self.assertEqual(response.status_code, 200)
     self.assertTrue(b'Please login to continue' in response.data)
示例#2
0
 def setUp(self):
     self.app = app.test_client()
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_memcache_stub()
     self.testbed.init_user_stub()
示例#3
0
 def setUp(self):
     config.google_api_key = config.google_api_key or 'PLACEHOLDER'
     from application import app, limiter
     self.uuid = str(uuid4())
     app.config['TESTING'] = True
     limiter.enabled = False
     self.app = app.test_client()
示例#4
0
文件: base.py 项目: xDuckoff/WebApp
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['TEST_DATABASE_URL']
     db.create_all()
     app.config['SOCKET_MODE'] = 'True'
     app.config['WTF_CSRF_ENABLED'] = False
     self.__mockUser()
     self.app = app.test_client()
示例#5
0
文件: tests.py 项目: rrc4/homegrown
    def setUp(self):
        app.testing = True

        self.client = app.test_client(use_cookies=True)

        self.app_context = app.test_request_context()
        self.app_context.push()
示例#6
0
文件: tests.py 项目: sgrizan/flamenco
 def setUp(self):
     #self.db_fd,
     app.config[
         'SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/server_test.sqlite'
     app.config['TESTING'] = True
     self.app = app.test_client()
     db.create_all()
 def setUp(self):
     self.app = app.test_client()
     app.config['WTF_CSRF_ENABLED'] = False
     with self.client.session_transaction() as session:
         session['full_name'] = 'Foo Bar'
         session['email_address'] = '*****@*****.**'
         session['organisation_name'] = 'Mock organisation'
示例#8
0
 def setUp(self):
     config.google_api_key = config.google_api_key or 'PLACEHOLDER'
     from application import app, limiter
     self.uuid = str(uuid4())
     app.config['TESTING'] = True
     limiter.enabled = False
     self.app = app.test_client()
示例#9
0
    def setUp(self):
        # First, create an instance of the Testbed class.
        self.testbed = testbed.Testbed()
        # Then activate the testbed, which prepares the service stubs for use.
        self.testbed.activate()
        # Next, declare which service stubs you want to use.
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()

        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False
        self.app = app.test_client()

        self.post = {
            'message_id': 1,
            'message_data': 'data'
        }
        self.put = {
            'message_id': 2,
            'message_data': 'data put',
        }

        self.initial = {
            'message_id': 1,
            'message_data': 'message data',
        }
示例#10
0
    def setUpClass(self):
        self.client = app.test_client()
        self.conn_object = DatabaseConnection()
        self.present_location = {'present_location': 'Bukumiro'}

        self.admin_user = {
            'username': '******',
            'password': '******',
            'email': '*****@*****.**'
        }

        self.user = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**"
        }

        self.user2 = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**"
        }
        self.client.post('/api/v2/signup',
                         data=json.dumps(self.user2),
                         content_type="application/json")
示例#11
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config['DEBUG'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///test.db"
     self.app = app.test_client()
     db.create_all()
 def setUp(self):
     self.myapp = app.test_client()
     self.myapp.testing = True    
     self.headers = {
         'ContentType': 'application/json',
         'dataType': 'json'
     }
示例#13
0
 def test_api_branches(self):
     tester = app.test_client(self)
     response = tester.get('/api/branches')
     data = json.loads(response.get_data())
     self.assertEqual(response.status_code, 200)
     self.assertEqual(data['results'][0]['id'],
                      "alfonsolzrg-add-instructions")
示例#14
0
 def setUp(self):
     # Flask apps testing. See: http://flask.pocoo.org/docs/testing/
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     app.config['FLASK_CONF'] = 'TEST'
     app.config['WTF_CSRF_ENABLED'] = False  # Needed to disable recaptcha.
     self.app = app.test_client()
示例#15
0
class TestRoute(unittest.TestCase):
    app.config['DATABASE_DISCOUNT'] = os.path.join(
        app.root_path, '../discount_codes_test.db')
    app.config['DATABASE_SERIAL'] = os.path.join(app.root_path,
                                                 '../serial_discount_test.db')
    client = app.test_client()

    def test_no_serial_in_route(self):
        rv = self.client.get('/discount')
        self.assertEqual(rv.get_json(),
                         {'error': 'Please enter a serial number'})
        self.assertEqual(rv.status_code, 400)

    def test_wrong_serial_in_route(self):
        rv = self.client.get('/discount?serial_number=wrong')
        self.assertEqual(rv.get_json(),
                         {'error': 'The serial number wrong is unknown'})
        self.assertEqual(rv.status_code, 404)

    def test_good_serial(self):
        rv = self.client.get(
            '/discount?serial_number=5ad/602d79c8-AX-b97c747299-d4250111d8f-CQ'
        )
        self.assertEqual(rv.get_json(), {'discount': 'pwYT9-CvnSS4oHL'})
        self.assertEqual(rv.status_code, 200)
 def setUp(self):
     create_db_dir = _basedir + "/db"
     if not os.path.exists(create_db_dir):
         os.mkdir(create_db_dir, 0755)
     app.config["TESTING"] = True
     app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(_basedir, "db/tests.db")
     self.app = app.test_client()
     db.create_all()
示例#17
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config[
         'URI'] = 'mysql+mysqlconnector://adminmaster:adminmaster2020@database-project-pachaqtec.cyzimxz00kka.us-east-1.rds.amazonaws.com:3306/pachaqtecDB'
     self.app = app.test_client()
     db.drop_all()
     db.create_all()
 def setUp(self):
     app.config['WTF_CSRF_ENABLED'] = False
     self.app = app.test_client()
     with self.client.session_transaction() as session:
         session['oauth_token'] = {'access_token': 'token'}
         session['oauth_user'] = {
             'permissions': ['signin', 'dashboard-editor']
         }
示例#19
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config['DEBUG'] = False
     app.config[
         "SQLALCHEMY_DATABASE_URI"] = f"postgresql://{creds['postgres_user']}:{creds['postgres_password']}@localhost:5432/test_db"
     self.app = app.test_client()
     db.create_all()
示例#20
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
         os.path.join(app.config['BASEDIR'], TEST_DB)
     self.app = app.test_client()
     db.drop_all()
     db.create_all()
 def setUp(self):
     app.config['WTF_CSRF_ENABLED'] = False
     self.app = app.test_client()
     with self.client.session_transaction() as session:
         session['oauth_token'] = {'access_token': 'token'}
         session['oauth_user'] = {
             'permissions': ['signin', 'dashboard-editor']
         }
示例#22
0
 def test_index_no_redirect(self):
     tester = app.test_client(self)
     response = tester.get(
         '/index',
         content_type='html/text',
         follow_redirects=False,
     )
     self.assertEqual(response.status_code, 302)
示例#23
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config[
         'SQLALCHEMY_DATABASE_URI'] = 'sqlite:////home/kevin/HonoursProject/tests/testDB.db'
     app.config['DEBUG'] = False
     self.app = app.test_client()
     db.create_all()
示例#24
0
    def setUpClass(cls):
        app.config[
            'SQLALCHEMY_DATABASE_URI'] = 'postgresql://{user}:{password}@{host}/{database}'.format(
                **config)
        app.app_context().push()
        db.init_app(app)

        cls.app = app.test_client()
示例#25
0
 def test_post(self):
     with app.test_client() as client:
         """
         Send data as POST form to endpoint
         """
         user_2 = {'username': '******', 'password': '******'}
         goodresult = client.post('/api', data=user_2)
         self.assertEqual(200, goodresult.status_code)
示例#26
0
    def setUp(self):
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False

        self.app = app.test_client()
        self.app.testing = True
        self.assertEqual(app.debug, False)
    def setUp(self):
        app.config.from_object('config.TestingConfig')
        self.client = app.test_client()

        db.init_app(app)
        with app.app_context():
            db.create_all()
            user_datastore.create_user(email='test', password=encrypt_password('test'))
            db.session.commit()
示例#28
0
 def test_login_unverifyed_password_credentials(self):
     tester = app.test_client(self)
     response = tester.post('/login',
                            data={
                                'username': '******',
                                'password': '******'
                            },
                            follow_redirects=True)
     self.assertIn(b'Username or password is incorrect', response.data)
示例#29
0
 def test_index_redirect(self):
     tester = app.test_client(self)
     response = tester.get(
         '/index',
         content_type='html/text',
         follow_redirects=True,
     )
     self.assertEqual(response.status_code, 200)
     self.assertTrue(b'Please log in to access this page.' in response.data)
示例#30
0
    def setUp(self):
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        app.config['SQLALCHEMY_DATABASE_URI'] = config.Config.SQLALCHEMY_DATABASE_URI
        self.app = app.test_client()
        db.create_all()

        self.assertEqual(app.debug, False)
示例#31
0
    def setUp(self):
        super(BusterTestCase, self).setUp()
        # Flask apps testing. See: http://flask.pocoo.org/docs/testing/
        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False
        self.app = app.test_client()

        self.set_response("https://alpha-api.app.net/stream/0/posts", content=FAKE_POST_OBJ_RESP, status_code=200, method="POST")
        self.clear_datastore()
示例#32
0
 def setUpClass(cls):
     # creates a test client
     app.config.from_object('config.testing')
     cls.app = app.test_client()
     # propagate the exceptions to the test client
     cls.app.testing = True
     db.drop_all()
     db.create_all()
     init_data()
示例#33
0
def client():
    db_fd, app.config['DATABASE'] = tempfile.mkstemp()
    app.config['TESTING'] = True

    with app.test_client() as client:
        yield client

    os.close(db_fd)
    os.unlink(app.config['DATABASE'])
示例#34
0
def client():
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database_test.db'

    app.config['TESTING'] = True

    with app.test_client() as client:
        with app.app_context():
            init_db()
        yield client
示例#35
0
 def setUp(self):
     create_db_dir = _basedir + '/db'
     if not os.path.exists(create_db_dir):
         os.mkdir(create_db_dir, 0755)
     app.config['TESTING'] = True
     app.config['SQLALCHEMY_DATABASE_URI'] = ('sqlite:///'
                                 + os.path.join(_basedir, 'db/tests.db'))
     self.app = app.test_client()
     db.create_all()
示例#36
0
 def setUp(self):
     create_db_dir = _basedir + '/db'
     if not os.path.exists(create_db_dir):
         os.mkdir(create_db_dir, 0755)
     app.config['TESTING'] = True
     app.config['SQLALCHEMY_DATABASE_URI'] = ('sqlite:///'
                                 + os.path.join(_basedir, 'db/tests.db'))
     self.app = app.test_client()
     db.create_all()
示例#37
0
 def test_login_unexisting_username_credentials(self):
     tester = app.test_client(self)
     response = tester.post('/login',
                            data={
                                'username': '******',
                                'password': '******'
                            },
                            follow_redirects=True)
     self.assertIn(b'Username or password is incorrect', response.data)
示例#38
0
 def test_login_correct_credentials(self):
     tester = app.test_client(self)
     response = tester.post('/login',
                            data={
                                'username': '******',
                                'password': '******'
                            },
                            follow_redirects=True)
     assert response.status == '200 OK'
示例#39
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     self.app = app.test_client()
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_user_stub()
     self.testbed.init_memcache_stub()
 def setUp(self):
     app.config['WTF_CSRF_ENABLED'] = False
     self.app = app.test_client()
     with self.client.session_transaction() as session:
         session['oauth_token'] = {'access_token': 'token'}
         session['oauth_user'] = {
             'permissions': ['signin', 'admin'],
             'name': 'Mr Foo Bar',
             'email': '*****@*****.**'
         }
 def setUp(self):
     app.config['WTF_CSRF_ENABLED'] = False
     self.app = app.test_client()
     with self.client.session_transaction() as session:
         session['oauth_token'] = {'access_token': 'token'}
         session['oauth_user'] = {
             'permissions': ['signin', 'admin'],
             'name': 'Mr Foo Bar',
             'email': '*****@*****.**'
         }
示例#42
0
 def setUp(self):
     # Flask apps testing. See: http://flask.pocoo.org/docs/testing/
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     self.app = app.test_client()
     # setup app engine test bed
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_user_stub()
示例#43
0
 def setUp(self):
     # Flask apps testing. See: http://flask.pocoo.org/docs/testing/
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     self.app = app.test_client()
     # Setups app engine test bed. See: http://code.google.com/appengine/docs/python/tools/localunittesting.html#Introducing_the_Python_Testing_Utilities
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_user_stub()
     self.testbed.init_memcache_stub()
示例#44
0
文件: tests.py 项目: CGTAdal/flamenco
 def setUp(self):
     # self.db_fd,
     app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////tmp/server_test.sqlite"
     app.config["TESTING"] = True
     self.app = app.test_client()
     db.create_all()
     # add fake worker
     worker = Worker(
         hostname="debian", status="enabled", connection="offline", system="Linux", ip_address="127.0.0.1", port=5000
     )
     db.session.add(worker)
     db.session.commit()
示例#45
0
    def setUp(self):
        config.google_api_key = config.google_api_key or 'PLACEHOLDER'

        self.uuid = str(uuid4())
        from application import app

        app.config['TESTING'] = True
        app.config['TESTING_GCM'] = []

        self.gcm = app.config['TESTING_GCM']
        self.app = app.test_client()
        self.app_real = app
示例#46
0
    def setUp(self):
        # Flask apps testing. See: http://flask.pocoo.org/docs/testing/
        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False
        self.app = app.test_client()

        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_user_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()
    def setUp(self):
        app.config['WTF_CSRF_ENABLED'] = False
        dash_id = '77f1351a-e62f-47fe-bc09-fc69723573be'
        self.app = app.test_client()
        self.upload_url = \
            '/dashboard/{}/digital-take-up/upload'.format(dash_id)
        self.file_data = {
            'file': (StringIO('Week ending,API,Paper form\n2014-08-05,40,10'),
                     'test_upload.csv')}

        self.upload_spreadsheet_patcher = patch(
            'application.controllers.upload.upload_spreadsheet')
        self.upload_spreadsheet_mock = self.upload_spreadsheet_patcher.start()
        self.upload_spreadsheet_mock.return_value = ([], False)
示例#48
0
    def setUp(self):
        """Stuff to do before every test."""

        # party like a rockstar, totally dude.
        print 'SETUP for Flask'

        # Get the Flask test client
        self.client = app.test_client()

        # Show Flask errors that happen during tests
        app.config['TESTING'] = True

        # Connect to test database
        # connect_to_db(app, "postgresql:///test_data")  # not using this now
        connect_to_db(app, "postgres:///crime_data_gis")
示例#49
0
 def setUp(self):
     #self.db_fd,
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/server_test.sqlite'
     app.config['TESTING'] = True
     self.app = app.test_client()
     db.create_all()
     # add fake worker
     worker = Worker(hostname='debian',
             status='enabled',
             connection='offline',
             system='Linux',
             ip_address='127.0.0.1',
             port=5000)
     db.session.add(worker)
     db.session.commit()
示例#50
0
 def setUpClass(self):
     # create app package
     pkg = ZipFile('test.zip', 'w')
     pkg.write('testapp/application.py', arcname='application.py')
     pkg.write('testapp/manifest.json', arcname='manifest.json')
     pkg.write('testapp/requirements.txt', arcname='requirements.txt')
     pkg.write('testapp/wsgi.py', arcname='wsgi.py')
     pkg.close()
     # run
     self.pkg = os.path.join(os.path.dirname('.'), 'test.zip')
     if not os.path.exists(self.pkg):
         raise RuntimeError('Error creating test package: {0}'.format(self.pkg))
     self.app = app.test_client()
     # monkey patch app to load custom test_settings
     utils.applications.app = create_app('test_settings')
     self.application = Application()
 def setUp(self):
     app.config['testing'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.debug = True
     app.secret_key = "something_secret"
     app.testing = True
     self.app = app.test_client()
     init_db('sqlite://')
     # login session
     query = dict(state='testingstate')
     self.app.post('/fbconnect', query_string=query, data='testytesttest')
     with open(test_image_name_1, 'r') as test_image:
         self.image_string = StringIO(test_image.read())
     with open(test_image_name_2, 'r') as test_image2:
         self.image2_string = StringIO(test_image2.read())
     del test_image
     del test_image2
    def setUp(self):
        self.dashboards = [
            {
                'url': 'http://stagecraft/dashboard/uuid',
                'public-url': 'http://spotlight/performance/carers-allowance',
                'published': True,
                'status': 'published',
                'id': 'uuid',
                'title': 'Name of service'
            }
        ]

        app.config['WTF_CSRF_ENABLED'] = False
        self.app = app.test_client()
        with self.client.session_transaction() as session:
            session['oauth_token'] = {'access_token': 'token'}
            session['oauth_user'] = {
                'permissions': ['signin', 'dashboard-editor']
            }
    def setUp(self):
        app.config['WTF_CSRF_ENABLED'] = False
        self.dash_id = '77f1351a-e62f-47fe-bc09-fc69723573be'
        self.app = app.test_client()
        self.upload_url = \
            '/dashboard/{}/cost-per-transaction/upload'.format(self.dash_id)
        self.file_data = {
            'file': (StringIO('Week ending,API,Paper form\n2014-08-05,40,10'),
                     'test_upload.csv')}

        self.upload_spreadsheet_patcher = patch(
            'application.controllers.upload.upload_spreadsheet')
        self.upload_spreadsheet_mock = self.upload_spreadsheet_patcher.start()
        self.upload_spreadsheet_mock.return_value = ([], False)

        self.generate_bearer_token_patcher = patch(
            "application.controllers.builder"
            ".cost_per_transaction.generate_bearer_token")
        self.generate_bearer_token_mock = \
            self.generate_bearer_token_patcher.start()
        self.generate_bearer_token_mock.return_value = "abc123def"
示例#54
0
    def setUp(self, **kwargs):
        eve_settings_file = os.path.join(MY_PATH, 'common_test_settings.py')
        pillar_config_file = os.path.join(MY_PATH, 'config_testing.py')
        kwargs['settings_file'] = eve_settings_file
        os.environ['EVE_SETTINGS'] = eve_settings_file
        os.environ['PILLAR_CONFIG'] = pillar_config_file
        super(AbstractPillarTest, self).setUp(**kwargs)

        from application import app

        logging.getLogger('').setLevel(logging.DEBUG)
        logging.getLogger('application').setLevel(logging.DEBUG)
        logging.getLogger('werkzeug').setLevel(logging.DEBUG)
        logging.getLogger('eve').setLevel(logging.DEBUG)

        from eve.utils import config
        config.DEBUG = True

        self.app = app
        self.client = app.test_client()
        assert isinstance(self.client, FlaskClient)
示例#55
0
文件: tests.py 项目: berg/pourover
    def setUp(self):
        super(BusterTestCase, self).setUp()
        # Flask apps testing. See: http://flask.pocoo.org/docs/testing/
        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False
        self.app = app.test_client()

        self.set_response("https://alpha-api.app.net/stream/0/posts", content=FAKE_POST_OBJ_RESP, status_code=200, method="POST")
        self.clear_datastore()

        taskqueue_stub = apiproxy_stub_map.apiproxy.GetStub('taskqueue')
        dircontainingqueuedotyaml = os.path.dirname(os.path.dirname(__file__))
        taskqueue_stub._root_path = dircontainingqueuedotyaml

        self.taskqueue_stub = taskqueue_stub
        self.set_response('http://i1.ytimg.com/vi/ABm7DuBwJd8/hqdefault.jpg?feature=og', content=FAKE_SMALL_IMAGE, method="GET")
        for i in xrange(0, 12):
            for b in xrange(0, 12):
                unique_key = 'test%s_%s' % (i, b)
                unique_key2 = 'test_%s' % (i)
                self.set_response('http://example.com/buster/%s' % (unique_key), content=HTML_PAGE_TEMPLATE_WITH_META % ({'unique_key': unique_key}))
                self.set_response('http://example.com/buster/%s' % (unique_key2), content=HTML_PAGE_TEMPLATE_WITH_META % ({'unique_key': unique_key2}))
示例#56
0
    def setUp(self):
        # do the normal setUp
        super(LoginTestCase, self).setUp()

        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False

        # Setup a test view
        @login_required
        def secret():
            """Temporary secret page"""
            return "Shhh! It's a secret!"

        # add the test view
        self.secret = secret
        app.add_url_rule('/secretTest', 'secret', self.secret)

        # redo the test client
        self.app = app.test_client()

        # make the fake users
        self.users = create_test_users()
示例#57
0
文件: tests.py 项目: CGTAdal/flamenco
 def setUp(self):
     #self.db_fd,
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/server_test.sqlite'
     app.config['TESTING'] = True
     self.app = app.test_client()
     db.create_all()
示例#58
0
 def setUp(self):
     self.app = app.test_client()
 def setUp(self):
     app.config['WTF_CSRF_ENABLED'] = False
     self.app = app.test_client()
示例#60
0
文件: testing.py 项目: physion/aker
    def setUp(self):
        from application import app

        app.config['TESTING'] = True
        self.app = app.test_client()