Update app.py
Browse files
app.py
CHANGED
@@ -3,11 +3,28 @@ import streamlit as st
|
|
3 |
import requests
|
4 |
import json
|
5 |
import sqlite3
|
|
|
6 |
from transformers import pipeline
|
7 |
|
8 |
# Load AI model for test case generation
|
9 |
test_case_generator = pipeline("text-generation", model="microsoft/CodeGPT-small-py")
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
def fetch_swagger_data(swagger_url):
|
12 |
try:
|
13 |
response = requests.get(swagger_url)
|
@@ -41,13 +58,14 @@ def store_test_results(test_case, result):
|
|
41 |
conn.commit()
|
42 |
conn.close()
|
43 |
|
|
|
44 |
def show_past_results():
|
45 |
-
conn = sqlite3.connect(
|
46 |
cursor = conn.cursor()
|
47 |
cursor.execute("SELECT * FROM results")
|
48 |
-
|
49 |
conn.close()
|
50 |
-
return
|
51 |
|
52 |
# Streamlit UI
|
53 |
st.title("AI-Powered API Test Case Generator")
|
|
|
3 |
import requests
|
4 |
import json
|
5 |
import sqlite3
|
6 |
+
import os
|
7 |
from transformers import pipeline
|
8 |
|
9 |
# Load AI model for test case generation
|
10 |
test_case_generator = pipeline("text-generation", model="microsoft/CodeGPT-small-py")
|
11 |
|
12 |
+
# Agar database file exist nahi karti toh create karo
|
13 |
+
if not os.path.exists(DB_PATH):
|
14 |
+
conn = sqlite3.connect(DB_PATH)
|
15 |
+
cursor = conn.cursor()
|
16 |
+
cursor.execute('''
|
17 |
+
CREATE TABLE IF NOT EXISTS results (
|
18 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
19 |
+
api_name TEXT,
|
20 |
+
test_status TEXT,
|
21 |
+
run_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
|
22 |
+
)
|
23 |
+
''')
|
24 |
+
conn.commit()
|
25 |
+
conn.close()
|
26 |
+
|
27 |
+
|
28 |
def fetch_swagger_data(swagger_url):
|
29 |
try:
|
30 |
response = requests.get(swagger_url)
|
|
|
58 |
conn.commit()
|
59 |
conn.close()
|
60 |
|
61 |
+
# Function to get past results
|
62 |
def show_past_results():
|
63 |
+
conn = sqlite3.connect(DB_PATH)
|
64 |
cursor = conn.cursor()
|
65 |
cursor.execute("SELECT * FROM results")
|
66 |
+
data = cursor.fetchall()
|
67 |
conn.close()
|
68 |
+
return data
|
69 |
|
70 |
# Streamlit UI
|
71 |
st.title("AI-Powered API Test Case Generator")
|