def test_myapp(): response = app.test_client().get('/') assert response.status_code == 200 # assert response.data == b'Hello, World!' #def test_myapp_status(): response = app.test_client().get('/status', follow_redirects=True) assert response.status_code == 200
def test_add_location(self): with app.test_client() as client: sent = { "pincode": "IN/500052", "place": "Hasannagar", "city": "Telangana", "latitude": 17.387140, "longitude": 78.491684, "accuracy": 0 } sent = json.dumps(sent) client.post('http://localhost:5000/delete_post_location', data=sent, content_type='application/json' ) #Delete the test entry if it exists result = client.post( 'http://localhost:5000/post_location', data=sent, content_type='application/json') #Add test entry print 'Test 11:', result.data client.post('http://localhost:5000/delete_post_location', data=sent, content_type='application/json' ) #Delete the test entry if it exists self.assertEqual(result.data, "location saved")
def test_similar_coordinates(self): with app.test_client() as client: sent = { "pincode": "IN/110334", "place": "Bharat Nagar", "city": "New Delhi", "latitude": 28.6400, "longitude": 77.2150, "accuracy": 0 } sent = json.dumps(sent) client.post('http://localhost:5000/delete_post_location', data=sent, content_type='application/json' ) #Delete the test entry if it exists result = client.post( 'http://localhost:5000/post_location', data=sent, content_type='application/json') #Add test entry print 'Test 10:', result.data client.post('http://localhost:5000/delete_post_location', data=sent, content_type='application/json' ) #Delete the test entry if it exists self.assertEqual(result.data, "place with similar coordinates exists")
def setUp(self): resource=blogArticleCollection.find_one() resourceId=str(resource["_id"]) usrId=resource["ownerId"] app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['DEBUG'] = False self.app = app.test_client()
def setUp(self): app.config['TESTING'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' app.check_auth = Mock(return_value=False) self.app = app.test_client() db.create_all() self.app = app.test_client() self.non_existing_user = '******' self.creds = ('service2', 'simple') self.owner = 'foobar' self.resources = ['321aa00a', '3432aaaa', 'fobara'] u = User(id=self.owner) for i in self.resources: u.resources.append(Resource(id=i)) db.session.add(u) db.session.commit()
def test_add_location(self): with app.test_client() as client: result1 = client.get( 'http://localhost:5000/get_using_postgres?lat1=10.777&lon1=8.965&distance=5000' ) result2 = client.get( 'http://localhost:5000/get_using_self?lat1=10.777&lon1=8.965&distance=5000000' ) print result1.data self.assertTrue(result1.data == result2.data)
def test_myapp(): from myapp import app with app.test_client("/", approot=".") as cli: # html request resp = cli.get("/") assert "something" in resp.text # api call resp = cli.api().apis.pets("45").get() assert "id" in resp.data
def test_player_setup_easy(test_game): client = app.test_client() url = "/" response = client.get(url) assert test_game.player.name == "tester" assert test_game.player.pilot == 4 assert test_game.player.fighter == 4 assert test_game.player.merchant == 4 assert test_game.player.engineer == 4 assert test_game.player.credit == 1000 assert test_game.player.karma == 0 assert response.status_code == 200
def test_place_type(self): with app.test_client() as client: sent = { "pincode": "110026", "place": 5.0, "city": "New Delhi", "latitude": 28.6488, "longitude": 77.1726, "accuracy": 0 } sent = json.dumps(sent) result = client.post('http://localhost:5000/post_location', data=sent, content_type='application/json') print 'Test 2:', result.data self.assertEqual(result.data, "place is not a string")
def test_existing_pincode(self): with app.test_client() as client: sent = { "pincode": "IN/110026", "place": "Punjabi Bagh", "city": "New Delhi", "latitude": 28.6488, "longitude": 77.1726, "accuracy": 0 } sent = json.dumps(sent) result = client.post('http://localhost:5000/post_location', data=sent, content_type='application/json') print 'Test 8:', result.data self.assertEqual(result.data, "place with the same pincode exists")
def test_lat_type2(self): with app.test_client() as client: sent = { "pincode": "110026", "place": "Punjabi Bagh", "city": "New Delhi", "latitude": "hello", "longitude": 77.1726, "accuracy": 0 } sent = json.dumps(sent) result = client.post('http://localhost:5000/post_location', data=sent, content_type='application/json') print 'Test 5:', result.data self.assertEqual(result.data, "latitude is not a float")
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['DEBUG'] = False self.app = app.test_client()
def client(): app.testing = True app.debug = True return app.test_client()
def client(): app.config['TESTING'] = True client = app.test_client() yield client
def setUp(self): app.config['TESTING'] = True app.config['CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test2.db' self.app = app.test_client() db.create_all()
def setUp(self): self.tester = app.test_client(self) app.config['TESTING'] = True
def client(): app.config['TESTING'] = True app.config['SERVER_NAME'] = 'localhost.localdomain' client = app.test_client() return client
def setUp(self): app.config["TESTING"] = True app.config["DEBUG"] = False self.app = app.test_client() self.assertEqual(app.debug, False)
def setUp(self): app.config['TESTING'] = True self.client = app.test_client(use_cookies=True)
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db') self.app = app.test_client() db.create_all()
def client(): with app.app_context(): db.create_all() app.testing = True app.debug = True return app.test_client()
def setUp(self): app.config.update(TESTING=True, WTF_CSRF_ENABLED=False, MONGO_DBNAME="testcase") self.client = app.test_client() self.runner = app.test_cli_runner()