import os import time import pytest import uuid from app import app def createFile(name, size): # create a file of random data with open(name, 'wb') as fout: fout.write(os.urandom(size)) # replace 1024 with size_kb if not unreasonably large @pytest.fixture def client(): app.config['TESTING'] = True # create fake pre-gen terrain files if they don't exist preGen = ['S35E149.DAT', 'S35E147.DAT', 'S30E137.DAT', 'S31E136.DAT', 'S31E137.DAT', 'S31E138.DAT', 'S30E136.DAT', 'S30E137.DAT', 'S30E138.DAT', 'S29E136.DAT', 'S29E137.DAT', 'S29E138.DAT'] for fileSingle in preGen: full = os.path.join(os.getcwd(), "processedTerrain", fileSingle) print(full) if not os.path.exists(full): print("Making fake file: " + full) createFile(full, 1024 * 1024) with app.test_client() as client: #with app.app_context(): # app.init_db() yield client #shutdown() def test_homepage(client): """Test that the homepage can be generated""" rv = client.get('/') # assert all the controls are there assert b'