|
@@ -17,22 +17,18 @@ def client():
|
|
|
app.config['TESTING'] = True
|
|
app.config['TESTING'] = True
|
|
|
|
|
|
|
|
# create fake pre-gen terrain files if they don't exist
|
|
# 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)
|
|
|
|
|
|
|
+ #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.test_client() as client:
|
|
|
- #with app.app_context():
|
|
|
|
|
- # app.init_db()
|
|
|
|
|
yield client
|
|
yield client
|
|
|
|
|
|
|
|
- #shutdown()
|
|
|
|
|
-
|
|
|
|
|
def test_homepage(client):
|
|
def test_homepage(client):
|
|
|
"""Test that the homepage can be generated"""
|
|
"""Test that the homepage can be generated"""
|
|
|
|
|
|
|
@@ -98,19 +94,38 @@ def test_simplegen(client):
|
|
|
|
|
|
|
|
assert b'<title>AP Terrain Generator</title>' in rv.data
|
|
assert b'<title>AP Terrain Generator</title>' in rv.data
|
|
|
assert b'Error' not in rv.data
|
|
assert b'Error' not in rv.data
|
|
|
|
|
+ assert b'Tiles outside of +60 to -60 latitude were requested' not in rv.data
|
|
|
assert b'download="terrain.zip"' in rv.data
|
|
assert b'download="terrain.zip"' in rv.data
|
|
|
|
|
|
|
|
uuidkey = (rv.data.split(b"footer")[1][1:-2]).decode("utf-8")
|
|
uuidkey = (rv.data.split(b"footer")[1][1:-2]).decode("utf-8")
|
|
|
assert uuidkey != ""
|
|
assert uuidkey != ""
|
|
|
|
|
|
|
|
- #wait for generator to complete, up to 1 second
|
|
|
|
|
- time.sleep(1)
|
|
|
|
|
-
|
|
|
|
|
#file should be ready for download and around 2MB in size
|
|
#file should be ready for download and around 2MB in size
|
|
|
rdown = client.get('/terrain/' + uuidkey + ".zip", follow_redirects=True)
|
|
rdown = client.get('/terrain/' + uuidkey + ".zip", follow_redirects=True)
|
|
|
|
|
+ assert b'404 Not Found' not in rdown.data
|
|
|
assert len(rdown.data) > (1*1024*1024)
|
|
assert len(rdown.data) > (1*1024*1024)
|
|
|
|
|
|
|
|
- #shutdown()
|
|
|
|
|
|
|
+def test_simplegenoutside(client):
|
|
|
|
|
+ """Test that a small piece of terrain can be generated with partial outside +-60latitude"""
|
|
|
|
|
+
|
|
|
|
|
+ rv = client.post('/generate', data=dict(
|
|
|
|
|
+ lat='-58.363261',
|
|
|
|
|
+ long='149.165230',
|
|
|
|
|
+ radius='200',
|
|
|
|
|
+ ), follow_redirects=True)
|
|
|
|
|
+
|
|
|
|
|
+ assert b'<title>AP Terrain Generator</title>' in rv.data
|
|
|
|
|
+ assert b'Error' not in rv.data
|
|
|
|
|
+ assert b'Tiles outside of +60 to -60 latitude were requested' in rv.data
|
|
|
|
|
+ assert b'download="terrain.zip"' in rv.data
|
|
|
|
|
+
|
|
|
|
|
+ uuidkey = (rv.data.split(b"footer")[1][1:-2]).decode("utf-8")
|
|
|
|
|
+ assert uuidkey != ""
|
|
|
|
|
+
|
|
|
|
|
+ #file should be ready for download and around 2MB in size
|
|
|
|
|
+ rdown = client.get('/terrain/' + uuidkey + ".zip", follow_redirects=True)
|
|
|
|
|
+ assert b'404 Not Found' not in rdown.data
|
|
|
|
|
+ assert len(rdown.data) > (0.25*1024*1024)
|
|
|
|
|
|
|
|
def test_multigen(client):
|
|
def test_multigen(client):
|
|
|
"""Test that a a few small piece of terrains can be generated"""
|
|
"""Test that a a few small piece of terrains can be generated"""
|
|
@@ -146,12 +161,10 @@ def test_multigen(client):
|
|
|
assert uuidkey != ""
|
|
assert uuidkey != ""
|
|
|
allUuid.append(uuidkey)
|
|
allUuid.append(uuidkey)
|
|
|
|
|
|
|
|
- #wait for generator to complete, up to 1 second
|
|
|
|
|
- time.sleep(1)
|
|
|
|
|
-
|
|
|
|
|
- #files should be ready for download and around 2MB in size
|
|
|
|
|
|
|
+ #files should be ready for download and around 0.7MB in size
|
|
|
for uukey in allUuid:
|
|
for uukey in allUuid:
|
|
|
rdown = client.get('/terrain/' + uukey + ".zip", follow_redirects=True)
|
|
rdown = client.get('/terrain/' + uukey + ".zip", follow_redirects=True)
|
|
|
|
|
+ assert b'404 Not Found' not in rdown.data
|
|
|
assert len(rdown.data) > (0.7*1024*1024)
|
|
assert len(rdown.data) > (0.7*1024*1024)
|
|
|
|
|
|
|
|
|
|
|