parent
93ee65fe53
commit
87f4347fe5
@ -1,44 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import pytest
|
||||
import backend
|
||||
from backend import store
|
||||
import os
|
||||
# https://github.com/pallets/flask/blob/1.1.2/examples/tutorial/tests/test_auth.py
|
||||
|
||||
# Much better boilerplate than the docs
|
||||
# https://www.python-boilerplate.com/py3+flask+pytest/
|
||||
|
||||
@pytest.fixture
|
||||
def app(request):
|
||||
|
||||
|
||||
datastore_path ="./test-datastore"
|
||||
try:
|
||||
os.mkdir(datastore_path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
# Kinda weird to tell them both where `datastore_path` is right..
|
||||
app_config = {'datastore_path': datastore_path}
|
||||
datastore = store.ChangeDetectionStore(datastore_path=app_config['datastore_path'])
|
||||
app = backend.changedetection_app(app_config, datastore)
|
||||
|
||||
|
||||
app.debug = True
|
||||
|
||||
def teardown():
|
||||
app.config['STOP_THREADS']=True
|
||||
print("teardown")
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
return app.test_client()
|
||||
|
||||
|
||||
def test_hello_world(app):
|
||||
res = app.get("/")
|
||||
# print(dir(res), res.status_code)
|
||||
assert res.status_code == 200
|
||||
assert b"IMPORT" in res.data
|
||||
|
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import pytest
|
||||
import backend
|
||||
from backend import store
|
||||
import os
|
||||
import time
|
||||
import requests
|
||||
# https://github.com/pallets/flask/blob/1.1.2/examples/tutorial/tests/test_auth.py
|
||||
|
||||
# Much better boilerplate than the docs
|
||||
# https://www.python-boilerplate.com/py3+flask+pytest/
|
||||
|
||||
|
||||
def test_import(session):
|
||||
res = session.get("/")
|
||||
assert b"IMPORT" in res.data
|
||||
assert res.status_code == 200
|
||||
|
||||
test_url_list = ["https://slashdot.org"]
|
||||
res = session.post('/import', data={'urls': "\n".join(test_url_list)}, follow_redirects=True)
|
||||
s = "{} Imported".format(len(test_url_list))
|
||||
|
||||
#p= url_for('test_endpoint', _external=True
|
||||
|
||||
assert bytes(s.encode('utf-8')) in res.data
|
||||
|
||||
for url in test_url_list:
|
||||
assert bytes(url.encode('utf-8')) in res.data
|
||||
|
||||
#response = requests.get('http://localhost:5000/random_string')
|
||||
#assert response.status_code == 200
|
||||
#assert response.json() == [{'id': 1}]
|
||||
|
||||
|
||||
def test_import_a(session):
|
||||
res = session.get("/")
|
||||
assert b"IMPORT" in res.data
|
||||
assert res.status_code == 200
|
Loading…
Reference in new issue