gradio
1import { describe, it, expect } from "vitest";
2import { verifyRequirements } from "./requirements";
3
4describe("verifyRequirements", () => {
5const allowedRequirements = [
6[
7"http://files.pythonhosted.org/packages/62/9c/0467dea0a064a998f94c33d03988f33efc744de1a2a550b56b38910cafa2/streamlit-1.13.0-py2.py3-none-any.whl"
8],
9[
10"https://files.pythonhosted.org/packages/62/9c/0467dea0a064a998f94c33d03988f33efc744de1a2a550b56b38910cafa2/streamlit-1.13.0-py2.py3-none-any.whl"
11]
12];
13allowedRequirements.forEach((requirements) => {
14it(`allows http: and https: schemes (requirements=${
15requirements[0].split(":")[0]
16})`, () => {
17expect(() => verifyRequirements(requirements)).not.toThrow();
18});
19});
20
21const notAllowedRequirements = [["emfs:/tmp/foo.whl"], ["file:/tmp/foo.whl"]];
22notAllowedRequirements.forEach((requirements) => {
23it(`throws an error if the requirements include a not allowed scheme (requirements=${JSON.stringify(
24requirements
25)})`, () => {
26expect(() => verifyRequirements(requirements)).toThrow();
27});
28});
29});
30