Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_build_real(app, httpserver: HTTPServer):
request_data = dict(
version_data={
"branch": "master",
"path": "snapshots",
"pubkey": "RWS1BD5w+adc3j2Hqg9+b66CvLR7NlHbsj7wjNVj0XGt/othDgIAOJS+",
},
target="ath79/generic",
store_path=app.config["STORE_PATH"],
cache_path=app.config["CACHE_PATH"],
upstream_url="https://downloads.cdn.openwrt.org",
version="SNAPSHOT",
profile="tplink_tl-wdr4300-v1",
packages={"tmux", "vim"},
)
result = build(request_data)
assert result["id"] == "tplink_tl-wdr4300-v1"
request_data = dict(
version_data={
"branch": "master",
"path": "snapshots",
"pubkey": "RWSrHfFmlHslUcLbXFIRp+eEikWF9z1N77IJiX5Bt/nJd1a/x+L+SU89",
},
target="testtarget/testsubtarget",
store_path=app.config["STORE_PATH"],
cache_path=app.config["CACHE_PATH"],
upstream_url="http://localhost:8001",
version="SNAPSHOT",
profile="testprofile",
packages=["test1"],
)
with pytest.raises(Exception) as execinfo:
result = build(request_data)
assert str(execinfo.value) == "packages must be type set not list"
request_data = dict(
version_data={
"branch": "master",
"path": "snapshots",
"pubkey": "RWSrHfFmlHslUcLbXFIRp+eEikWF9z1N77IJiX5Bt/nJd1a/x+L+SU89",
},
target="testtarget/testsubtarget",
store_path=app.config["STORE_PATH"],
cache_path=app.config["CACHE_PATH"],
upstream_url="http://localhost:8001",
version="SNAPSHOT",
profile="testprofile",
)
with pytest.raises(Exception) as execinfo:
result = build(request_data)
assert str(execinfo.value) == "store_path must be existing directory"
def test_build_fake(app, upstream):
request_data = dict(
version_data={
"branch": "master",
"path": "snapshots",
"pubkey": "RWSrHfFmlHslUcLbXFIRp+eEikWF9z1N77IJiX5Bt/nJd1a/x+L+SU89",
},
target="testtarget/testsubtarget",
store_path=app.config["STORE_PATH"],
cache_path=app.config["CACHE_PATH"],
upstream_url="http://localhost:8001",
version="SNAPSHOT",
profile="testprofile",
packages={"test1", "test2"},
)
result = build(request_data)
assert result["id"] == "testprofile"
def test_build_fake_no_packages(app, upstream):
request_data = dict(
version_data={
"branch": "master",
"path": "snapshots",
"pubkey": "RWSrHfFmlHslUcLbXFIRp+eEikWF9z1N77IJiX5Bt/nJd1a/x+L+SU89",
},
target="testtarget/testsubtarget",
store_path=app.config["STORE_PATH"],
cache_path=app.config["CACHE_PATH"],
upstream_url="http://localhost:8001",
version="SNAPSHOT",
profile="testprofile",
)
result = build(request_data)
assert result["id"] == "testprofile"
request_data = dict(
version_data={
"branch": "master",
"path": "snapshots",
"pubkey": "RWSrHfFmlHslUcLbXFIRp+eEikWF9z1N77IJiX5Bt/nJd1a/x+L+SU89",
},
target="testtarget/testsubtarget",
store_path=app.config["STORE_PATH"],
cache_path=app.config["CACHE_PATH"],
upstream_url="http://localhost:8001",
version="SNAPSHOT",
profile="testprofile",
packages={"test1", "test2"},
diff_packages=True,
)
result = build(request_data)
assert result["id"] == "testprofile"
@app.route("/api/v1/stats/images_latest")
def api_stats_images_latest():
return mime_json(database.get_images_latest())
@app.route("/api/manifest/")
def api_manifest(manifest_hash):
return mime_json(database.get_manifest_info(manifest_hash))
@app.route("/api/v1/stats/popular_packages")
def api_stats_popular_packages():
return mime_json(database.get_popular_packages())
@app.route("/api/v1/stats/popular_targets")
def api_stats_popular_targets():
return mime_json(database.get_popular_targets())