generated from nogibjj/Eric_Ortega_Rodriguez_Mini_Project_5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_main.py
91 lines (76 loc) · 2.42 KB
/
test_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import unittest
from unittest.mock import patch
from main import main
class TestMainFunction(unittest.TestCase):
@patch('main.load_dotenv')
@patch('main.extract')
@patch('main.load')
@patch('main.general_query')
def test_main(self, mock_general_query, mock_load, mock_extract, mock_load_dotenv):
main() # Run the main function
mock_load_dotenv.assert_called_once()
mock_extract.assert_called_once()
mock_load.assert_called_once()
mock_general_query.assert_called_once()
if __name__ == '__main__':
unittest.main()
# import os
# import sqlite3
# from mylib.query import query, create_entry
# def setup_test_db():
# """Create a temporary test database with sample data"""
# db_name = "test_avengers.db"
# conn = sqlite3.connect(db_name)
# cursor = conn.cursor()
# # Avengers table
# cursor.execute(
# """
# CREATE TABLE IF NOT EXISTS Avengers (
# URL TEXT,
# Name_Alias TEXT,
# Appearances INTEGER,
# Current TEXT,
# Gender TEXT,
# Probationary_Introl TEXT,
# Full_Reserve_Avengers_Intro TEXT,
# Year INTEGER,
# Years_since_joining INTEGER,
# Honorary TEXT,
# Death1 TEXT,
# Return1 TEXT,
# Death2 TEXT,
# Return2 TEXT,
# Death3 TEXT,
# Return3 TEXT,
# Death4 TEXT,
# Return4 TEXT,
# Death5 TEXT,
# Notes TEXT
# )
# """
# )
# # Insert sample data
# entry_data = (
# 'http://example.com', 'New Avenger', 100, 'YES', 'MALE', 'Intro Test',
# 'Full Member', 2022, 1, 'NO', 'NO', 'NO', 'NO', 'NO', 'NO', 'NO', 'NO',
# 'NO', 'NO', 'Test Notes'
# )
# create_entry(db_name, "Avengers", entry_data)
# conn.commit()
# conn.close()
# def test_query():
# """Test the query function"""
# db_name = "test_avengers.db"
# table_name = "Avengers"
# # Setup the test database
# if not os.path.exists(db_name):
# setup_test_db()
# # Test the query function
# result = query(database=db_name, table=table_name)
# # Assertions
# assert result is not None
# assert len(result) == 5
# if __name__ == "__main__":
# # Run the test
# test_query()
# print("Test completed successfully.")