• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python app.test_client函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中server.app.test_client函数的典型用法代码示例。如果您正苦于以下问题:Python test_client函数的具体用法?Python test_client怎么用?Python test_client使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了test_client函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_login

    def test_login(self):
        """Checks that a user is in session after login with correct credentials."""

        sys.stdout.write('Testing login handler...')
        with app.test_client() as c:
            self.login(c)
            assert User.query.filter(User.username=='janet').one().id == 1
开发者ID:janet,项目名称:choreme,代码行数:7,代码来源:tests.py


示例2: setUp

    def setUp(self):
        """Stuff to do before every test."""

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

        # Connect to test database
        connect_to_db(app)

        # Create tables and add sample data
        db.create_all()
        _example_data()

        app.config['TESTING'] = True
        app.config['SECRET_KEY'] = 'Aisling'
        self.client = app.test_client()
开发者ID:Aisling-Dempsey,项目名称:Haven,代码行数:16,代码来源:tests.py


示例3: setUp

    def setUp(self):
        """Setup to do before every test."""

        # Get the Flask test client
        self.client = app.test_client()
        app.jinja_env.undefined = StrictUndefined
        app.jinja_env.filters['prettify_preference'] = prettify_preference

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

        # Connect to test database
        connect_to_db(app, db_uri="postgresql:///testdb")

        # start with empty db
        db.drop_all()
        # Create tables and add sample data
        db.create_all()
        # create db records for yarns, users, baskets, basket_yarns,
        #                       projects, and patterns
        create_example_data()
        # create db records for preferences and user_preferences
        load_preferences("test_data/preference_data.txt")
        load_user_preferences("test_data/user_preference_data.txt")
        load_group_events("test_data/group-events.csv")
开发者ID:karayount,项目名称:commuKNITty,代码行数:25,代码来源:test_server.py


示例4: setUp

    def setUp(self):
        """Do before every test."""

        # 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:///testdb")
        db.create_all()

        # Make mocks
        def _mock_get_yelp_search_results(term, location, category_filter, limit):
            """Mocks search results of Yelp API call for one restaurant."""

            search_results = {"businesses": [{"rating": 4.5, "rating_img_url": "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/99493c12711e/ico/stars/v1/stars_4_half.png", "review_count": 547, "name": "Saru Sushi Bar", "rating_img_url_small": "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/a5221e66bc70/ico/stars/v1/stars_small_4_half.png", "url": "http://www.yelp.com/biz/saru-sushi-bar-san-francisco?utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=6XuCRI2pZ5pIvcWc9SI3Yg", "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/5-ugy01zjSvudVsfdhmCsA/ms.jpg", "display_phone": "+1-415-400-4510", "id": "saru-sushi-bar-san-francisco", "location": {"city": "San Francisco", "postal_code": "94114", "country_code": "US", "address": ["3856 24th St"], "coordinate": {"latitude": 37.751706, "longitude": -122.4288283}, "state_code": "CA"}}]}
            return search_results

        def _mock_is_open_now_true(keyword, location):
            """Mocks Google Places API call to return True for current open status."""

            return True

        self._old_is_open_now = process_results.is_open_now
        process_results.is_open_now = _mock_is_open_now_true

        self.old_get_yelp_search_results = server.yelp.search_query
        server.yelp.search_query = _mock_get_yelp_search_results
开发者ID:anniehe,项目名称:wait-time,代码行数:30,代码来源:tests.py


示例5: test_login

    def test_login(self):
        """Checks that a user is in session after login with correct credentials."""

        sys.stdout.write('Testing login handler...')
        with app.test_client() as c:
            self.login(c)
            assert flask.session['email'] == "[email protected]"
开发者ID:kaesackett,项目名称:RoomEase,代码行数:7,代码来源:test.py


示例6: setUp

    def setUp(self):
        print "\n\n\n\n (2) DOING A SEARCH TEST \n\n\n\n"
        self.client = app.test_client()
        app.config['TESTING'] = True
        postgrespassword = os.environ['POSTGRES_PASSWORD']
        db_uri = 'postgresql://' + postgrespassword + '/test'
        connect_to_db(app, db_uri)

        db.create_all()

        load_regions()
        load_users()
        load_bestuses()
        load_categories()
        load_brands()
        load_products()
        load_tents()
        load_filltypes()
        load_gendertypes()
        load_sleepingbags()
        load_padtypes()
        load_sleepingpads()
        load_ratings()
        load_histories()
        load_test_postalcodes()
开发者ID:fwong03,项目名称:watermelon,代码行数:25,代码来源:camper_tests.py


示例7: setUp

    def setUp(self):
        """Do at the beginning of every test"""
        # 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:///testdb")

        # Create tables from model
        db.create_all()

        # Import different types of data from seed file
        seed.load_users()
        seed.load_groups()
        seed.load_usergroups()
        seed.load_patterns()
        seed.load_invites()
        
        # Reset auto incrementing primary keys to start after seed data
        seed.set_val_user_id()
        seed.set_val_group_id()
        seed.set_val_usergroup_id()
        seed.set_val_pattern_id()
        seed.set_val_invite_id()

        with self.client as c:
                with c.session_transaction() as sess:
                    sess['user_id'] = 1
                c.set_cookie('localhost', 'MYCOOKIE', 'cookie_value')
开发者ID:ltaziri,项目名称:Hackbright-FinalProject,代码行数:32,代码来源:flaskr_tests.py


示例8: setUp

 def setUp(self):
 	"""Set up a blank temp database before each test"""
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, TEST_DB)
     self.app = app.test_client()
     db.create_all()
开发者ID:Nerevarsoul,项目名称:bookmark,代码行数:7,代码来源:tests.py


示例9: test_homepage

    def test_homepage(self):
        self.client = app.test_client()
        result = self.client.get("/")
        print dir(result) #### status_code, content_type=HTML, data

        self.asserIn("here", result.data)
        self.assertEqual(result.status_code,200)
开发者ID:Francydijesi,项目名称:hackbright_project,代码行数:7,代码来源:test.py


示例10: test_Classifier_data

 def test_Classifier_data(self):
     print 'Test for proper csv saving'
     tester = app.test_client(self)
     fingers_data = [
         [0,1,2,3,4],
         [1,2,3,4,5],
         [2,3,4,5,6],
         [3,4,5,6,7]
     ]
     response = tester.post('/data', data=dict(
         exercise = 0,
         fingers = fingers_data, 
         time = 666,
         success = 0,
         pain = 1
         ), follow_redirects=True);
     f = open('classificationData.csv' ,'r')
     reader = csv.reader(f,delimiter=',', quotechar='|')
     header = reader.next()
     self.assertEqual(header[0], 'finger1')
     firstRow = reader.next()
     self.assertEqual(int(firstRow[0]), 0)
 
     self.assertEqual(int(firstRow[5]), 1)
     os.remove('classificationData.csv')
     assert json.loads(response.data)
开发者ID:castillejoale,项目名称:aliviara,代码行数:26,代码来源:test.py


示例11: setUp

    def setUp(self):
        """Stuff to do before every test."""

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

        # Mock session

        # Connect to temporary database
        connect_to_db(app, "sqlite:///")

        # Create tables and add sample data
        db.create_all()
        sample_data()


        def _mock_grab_image_dimensions(filename):
            return (920, 764)

        self._old_grab_image_dimensions = server.grab_image_dimensions
        server.grab_image_dimensions = _mock_grab_image_dimensions

        def _mock_generate_thumb(filename, crop_thumb):
            return None

        self._old_generate_thumb = server.generate_thumb
        server.generate_thumb = _mock_generate_thumb
开发者ID:zewlie,项目名称:wildally-project,代码行数:27,代码来源:tests.py


示例12: setUp

    def setUp(self):
        self.client = app.test_client()
        app.config['TESTING'] = True
        app.config['SECRET_KEY'] = 'key'

        # Connect to test database
        connect_to_db(app, "postgresql:///testdb")
开发者ID:tinapastelero,项目名称:hacker-table,代码行数:7,代码来源:tests.py


示例13: setUp

 def setUp(self):
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(app.root_path, 'test.db')
     self.app = app.test_client()
     server.clean_db()
     db.create_all()
开发者ID:bourdibay,项目名称:MinimalistPythonFlaskServer,代码行数:7,代码来源:server_tests.py


示例14: setUp

    def setUp(self):
        self.client = app.test_client()
        app.config["TESTING"] = True
        app.config["SECRET_KEY"] = "key"

        with self.client.session_transaction() as sess:
            sess["user_id"] = 1
            sess["username"] = "Ada"
开发者ID:ibhan88,项目名称:Project---Vegan-Recipes,代码行数:8,代码来源:tests.py


示例15: setUp

 def setUp(self):
     self.app = app.test_client()
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
     app.config['TESTING'] = True
     app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
     db.app = app
     db.init_app(app)
     db.create_all()
开发者ID:eileenconner,项目名称:law-admissions-tool,代码行数:8,代码来源:tests2.py


示例16: setUp

	def setUp(self):
		app.config.from_object('config.TestingConfig')
		self.client = app.test_client()

		with app.app_context():
			init_app()
			user_datastore.create_user(email='test', password=encrypt_password('test'))
			db.session.commit()
开发者ID:LACMTA,项目名称:places,代码行数:8,代码来源:test.py


示例17: setUp

    def setUp(self):
        self.client = app.test_client()
        app.config['TESTING'] = True

        connect_to_db(app, "postgresql:///testdb")

        db.create_all()
        example_data_high_scores()
开发者ID:cachar,项目名称:flashcard-app,代码行数:8,代码来源:test.py


示例18: setUp

	def setUp(self):
		"""Stuff to do before every test."""
		self.client = app.test_client()
		app.config['TESTING'] = True


		self.test_YP = YumPossibilities(37.773972, -122.431297, 'brunch')
		server.call_yelp = self._mock_call_yelp
开发者ID:paigebernier,项目名称:HB-Project-Leggo,代码行数:8,代码来源:test_adventure.py


示例19: setUp

    def setUp(self):
        """Stuff to do before every test."""

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

        # Show Flask errors that happen during tests
        app.config['TESTING'] = True
开发者ID:barneygovan,项目名称:bouldering_project,代码行数:8,代码来源:test.py


示例20: setUp

 def setUp(self):
     self.client = app.test_client()
     app.config['TESTING'] = True
     app.config['SECRET_KEY'] = 'BalloonicornSmash'
     # Connect to the database
     connect_to_db(app, db_uri=travis_db_uri)
     # Reset the world so we start with clean data
     seed_force(app)
开发者ID:nija,项目名称:hb-chatty,代码行数:8,代码来源:tests.py



注:本文中的server.app.test_client函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python auth.user_mediacloud_key函数代码示例发布时间:2022-05-27
下一篇:
Python app.run函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap