Spaces:
Build error
Build error
Canstralian
commited on
Create test_app.py
Browse files- test_app.py +23 -0
test_app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# test_app.py
|
2 |
+
|
3 |
+
from app import sanitize_input, load_model, generate_text, load_json_data
|
4 |
+
|
5 |
+
def test_sanitize_input():
|
6 |
+
assert sanitize_input("Hello, World!") == "Hello, World!"
|
7 |
+
assert sanitize_input("Hello@#$") == "Hello"
|
8 |
+
assert sanitize_input(123) == "Input must be a string."
|
9 |
+
|
10 |
+
def test_load_model():
|
11 |
+
model, tokenizer = load_model()
|
12 |
+
assert model is not None
|
13 |
+
assert tokenizer is not None
|
14 |
+
|
15 |
+
def test_load_json_data():
|
16 |
+
data = load_json_data()
|
17 |
+
assert isinstance(data, list)
|
18 |
+
assert "name" in data[0]
|
19 |
+
|
20 |
+
def test_generate_text():
|
21 |
+
model, tokenizer = load_model()
|
22 |
+
result = generate_text(model, tokenizer, "Describe pentesting.")
|
23 |
+
assert isinstance(result, str)
|