File size: 696 Bytes
73b26c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# test_app.py

from app import sanitize_input, load_model, generate_text, load_json_data

def test_sanitize_input():
    assert sanitize_input("Hello, World!") == "Hello, World!"
    assert sanitize_input("Hello@#$") == "Hello"
    assert sanitize_input(123) == "Input must be a string."

def test_load_model():
    model, tokenizer = load_model()
    assert model is not None
    assert tokenizer is not None

def test_load_json_data():
    data = load_json_data()
    assert isinstance(data, list)
    assert "name" in data[0]

def test_generate_text():
    model, tokenizer = load_model()
    result = generate_text(model, tokenizer, "Describe pentesting.")
    assert isinstance(result, str)