def setUp(self): app.testing = True self.app = app.test_client() self.url = '/api/example/color' self.headers = { 'accept': 'application/json', 'Content-Type': 'application/json' }
def test_post_no_content(self, getMalwareRecords): with app.test_client() as client: rv = client.post("/mitre") expected_args = ("/", []) expected_status_code = 200 expected_response = {"data": []} getMalwareRecords.assert_called_with(*expected_args) self.assertEqual(rv.status_code, expected_status_code) self.assertEqual(json.loads(rv.get_data()), expected_response)
def setUp(self): app.config['redis'] = fakeredis.FakeRedis() app.testing = True # Keys used in redis for different types app.config['dbkeys'] = _set_db_keys() # capnp schemas used to serialize type into database app.config['capnp'] = _load_capnp_schemas() self.app = app.test_client()
def setUp(self): # get application for testing self.app = app.test_client() # get testing mongo client and database self.db_name = urlsplit(app.config['MONGODB_URI']).path[1:] self.mongo_client = MongoClient(app.config['MONGODB_URI']) self.mongo_db = self.mongo_client[self.db_name] # login into the application via test login endpoint self.app.get('/test_login')
def setUp(self): """ Creates a new database for the unit test to use """ app.config.from_pyfile('test_config.py') db.init_app(app) db.create_all() self.dataCleaner = DataCleaner(test_config.SQLALCHEMY_DATABASE_URI) self.app = app.test_client() return self.app
def setUp(self): """ Creates a new database for the unit test to use """ app.config.from_pyfile('test_config.py') db.init_app(app) db.create_all() self.app = app.test_client() self.eventsScraper = EventsScraper( 'scraper/test_data/test_pages_data.json') return self.app
def test_app(): '''Uses ``app`` imported from flask_app to create a testable Flask application. :yield: Flask application with a context, ready for testing ''' # global app # Uses global variable "app" app.config['TESTING'] = True test_app = app.test_client() ctx = app.app_context() ctx.push() yield test_app ctx.pop()
def test_post_no_keys(self, getMalwareRecords): with app.test_client() as client: path = "/path" rv = client.post( "/mitre", data=json.dumps(dict(path=path)), content_type="application/json", ) expected_args = (path, []) expected_status_code = 200 expected_response = {"data": []} getMalwareRecords.assert_called_with(*expected_args) self.assertEqual(rv.status_code, expected_status_code) self.assertEqual(json.loads(rv.get_data()), expected_response)
def test_delete(self): with app.test_client() as client: rv = client.delete("/mitre") expected_status_code = 405 self.assertEqual(rv.status_code, expected_status_code)
def client(): app.config["TESTING"] = True client = app.test_client() return client
def setUp(self): app.testing = True self.app = app.test_client()
def client(request): test_client = app.test_client() return test_client
def setUp(self): self.client = app.test_client()
def client(): app.config['TESTING'] = True with app.test_client() as client: yield client