add tests
This commit is contained in:
parent
7a37b73db0
commit
b08f274274
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ pyinfra.egg-info
|
||||
bamboo-specs/target
|
||||
.pytest_cache
|
||||
/.coverage
|
||||
.idea
|
||||
@ -13,3 +13,11 @@ storage:
|
||||
connection_string: "DefaultEndpointsProtocol=https;AccountName=iqserdevelopment;AccountKey=4imAbV9PYXaztSOMpIyAClg88bAZCXuXMGJG0GA1eIBpdh2PlnFGoRBnKqLy2YZUSTmZ3wJfC7tzfHtuC6FEhQ==;EndpointSuffix=core.windows.net"
|
||||
|
||||
bucket: "pyinfra-test-bucket"
|
||||
|
||||
webserver:
|
||||
host: $SERVER_HOST|"127.0.0.1" # webserver address
|
||||
port: $SERVER_PORT|5000 # webserver port
|
||||
mode: $SERVER_MODE|production # webserver mode: {development, production}
|
||||
|
||||
|
||||
mock_analysis_endpoint: "http://127.0.0.1:5000"
|
||||
24
pyinfra/test/mock_analyzer.py
Normal file
24
pyinfra/test/mock_analyzer.py
Normal file
@ -0,0 +1,24 @@
|
||||
import json
|
||||
from multiprocessing import Process
|
||||
|
||||
from flask import Flask, request, jsonify
|
||||
from pyinfra.test.config import CONFIG
|
||||
|
||||
|
||||
def start_mock_analyzer():
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/", methods=["POST"])
|
||||
def predict_request():
|
||||
|
||||
data = request.data
|
||||
section_text = json.loads(data)
|
||||
|
||||
return jsonify(section_text)
|
||||
|
||||
@app.get("/shut_down")
|
||||
def shut_down():
|
||||
request.environ.get('werkzeug.server.shutdown')
|
||||
|
||||
server = Process(target=app.run(host=CONFIG.webserver.host, port=CONFIG.webserver.port, debug=True))
|
||||
server.start()
|
||||
20
pyinfra/test/unit_tests/core_test.py
Normal file
20
pyinfra/test/unit_tests/core_test.py
Normal file
@ -0,0 +1,20 @@
|
||||
from time import sleep
|
||||
|
||||
from pyinfra.core import make_analyzer
|
||||
from pyinfra.test.config import CONFIG
|
||||
from pyinfra.test.mock_analyzer import start_mock_analyzer
|
||||
import requests
|
||||
|
||||
|
||||
def test_analyse():
|
||||
data = {"test": "Bliblablub"}
|
||||
start_mock_analyzer()
|
||||
sleep(5)
|
||||
analyzer = make_analyzer(CONFIG.mock_analysis_endpoint)
|
||||
assert analyzer(data) == data
|
||||
|
||||
requests.get(CONFIG.mock_analysis_endpoint + "/shut_down")
|
||||
|
||||
|
||||
def test_make_payload_processor_yields_dossier_id_file_id_predictions():
|
||||
pass
|
||||
Loading…
x
Reference in New Issue
Block a user