I want to test my flask application which is hosted on different machine (eg - staging machie to verify if all the api unit tests are passing), Can I override the flask base url in flask test client?
Currently all tests are run on DEV local machine.
class TestAPI(unittest.TestCase):
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
create_fake_data(db)
self.client = self.app.test_client()
def tearDown(self):
....
def test_post_panel_with_good_data(self):
# data
r = self.client.post('/customer',
data=json.dumps(data),
follow_redirects=True)
print(r.data)
self.assertEqual(r.status_code, 200)
Here flask test client self.client.post('/customer' ... )
generates the final URL using local machine but I want to pass custom base url so that final url can look something like this http://192.168.12.8/customer
.
r = self.client.post('/customer',
data=json.dumps(data),
follow_redirects=True)
Please suggest a way to run test using custom base url.