kahoot-to-anki 1.0.0__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tests/test_project.py DELETED
@@ -1,226 +0,0 @@
1
- # Standard library imports
2
- import shutil
3
- import os
4
-
5
- # Third-party library imports
6
- import numpy as np
7
- import pandas as pd
8
- import pytest
9
-
10
- # Local application/library imports
11
- import converter
12
-
13
-
14
- def generate_test_data():
15
- # Create multiple lists
16
- question_number = [
17
- "Question 1",
18
- "Question 1",
19
- "Question 1",
20
- "Question 2",
21
- "Question 2",
22
- "Question 2",
23
- ]
24
- question = [
25
- "How is a code block indicated in Python?",
26
- "How is a code block indicated in Python?",
27
- "How is a code block indicated in Python?",
28
- "Which of the following concepts is not a part of Python?",
29
- "Which of the following concepts is not a part of Python?",
30
- "Which of the following concepts is not a part of Python?",
31
- ]
32
- answer_1 = [
33
- "Brackets",
34
- "Brackets",
35
- "Brackets",
36
- "Pointers",
37
- "Pointers",
38
- "Pointers",
39
- ]
40
- answer_2 = [
41
- "Indentation",
42
- "Indentation",
43
- "Indentation",
44
- "Loops",
45
- "Loops",
46
- "Loops",
47
- ]
48
- answer_3 = [
49
- "Key",
50
- "Key",
51
- "Key",
52
- "Dynamic Typing",
53
- "Dynamic Typing",
54
- "Dynamic Typing",
55
- ]
56
- answer_4 = [
57
- np.nan,
58
- np.nan,
59
- np.nan,
60
- np.nan,
61
- np.nan,
62
- np.nan,
63
- ]
64
- answer_5 = [
65
- np.nan,
66
- np.nan,
67
- np.nan,
68
- np.nan,
69
- np.nan,
70
- np.nan,
71
- ]
72
- answer_6 = [
73
- np.nan,
74
- np.nan,
75
- np.nan,
76
- np.nan,
77
- np.nan,
78
- np.nan,
79
- ]
80
- correct_answers = [
81
- "Indentation",
82
- "Indentation",
83
- "Indentation",
84
- "Pointers",
85
- "Pointers",
86
- "Pointers",
87
- ]
88
- time_to_answer = [
89
- "10",
90
- "10",
91
- "10",
92
- "10",
93
- "10",
94
- "10",
95
- ]
96
- player = [
97
- "Harry",
98
- "Hermione ",
99
- "Ron",
100
- "Harry",
101
- "Hermione ",
102
- "Ron",
103
- ]
104
- answer = [
105
- "Indentation",
106
- "Indentation",
107
- "Brackets",
108
- "Dynamic Typing",
109
- "Pointers",
110
- "Dynamic Typing",
111
- ]
112
- correct_incorrect = [
113
- True,
114
- True,
115
- False,
116
- False,
117
- True,
118
- False,
119
- ]
120
- columns = [
121
- "Question Number",
122
- "Question",
123
- "Answer 1",
124
- "Answer 2",
125
- "Answer 3",
126
- "Answer 4",
127
- "Answer 5",
128
- "Answer 6",
129
- "Correct Answers",
130
- "Time Allotted to Answer (seconds)",
131
- "Player",
132
- "Answer",
133
- "Correct / Incorrect",
134
- ]
135
-
136
- # Create DataFrame from multiple lists
137
- df = pd.DataFrame(
138
- list(
139
- zip(
140
- question_number,
141
- question,
142
- answer_1,
143
- answer_2,
144
- answer_3,
145
- answer_4,
146
- answer_5,
147
- answer_6,
148
- correct_answers,
149
- time_to_answer,
150
- player,
151
- answer,
152
- correct_incorrect,
153
- )
154
- ),
155
- columns=columns,
156
- )
157
- return df
158
-
159
-
160
- @pytest.fixture(scope="session", autouse=True)
161
- def setup_and_teardown():
162
- test_data_dir = "test_data"
163
- test_data_dir_empty = "test_data_empty"
164
- input_file_name = "input.xlsx"
165
- empty_file_name = "empty.xlsx"
166
-
167
- input_file_path = os.path.join(test_data_dir, input_file_name)
168
- empty_file_path = os.path.join(test_data_dir, empty_file_name)
169
-
170
- df = generate_test_data()
171
-
172
- os.makedirs(test_data_dir, exist_ok=True)
173
- df.to_excel(input_file_path, sheet_name="RawReportData Data", index=False)
174
-
175
- os.makedirs(test_data_dir_empty, exist_ok=True)
176
-
177
- # create empty excel
178
- df_empty = pd.DataFrame()
179
- df_empty.to_excel(empty_file_path)
180
-
181
- # Yield to allow the test to run
182
- yield
183
-
184
- # Teardown: Cleanup the created files
185
- if os.path.exists(test_data_dir):
186
- shutil.rmtree(test_data_dir)
187
- if os.path.exists(test_data_dir_empty):
188
- shutil.rmtree(test_data_dir_empty)
189
-
190
-
191
- def test_validation_wrong_output():
192
- with pytest.raises(ValueError):
193
- assert converter.validation("test_data/", "test_data/input.xlsx")
194
-
195
-
196
- def test_validation_wrong_input_file():
197
- with pytest.raises(FileNotFoundError):
198
- assert converter.validation("test_data/in.txt", "test_data/")
199
-
200
-
201
- def test_validation_empty_input_directory():
202
- with pytest.raises(FileNotFoundError):
203
- assert converter.validation("test_data_empty/", "./output")
204
-
205
-
206
- def test_validation():
207
- assert converter.validation('./test_data/', "./test_data/") is None
208
-
209
-
210
- def test_get_questions_wrong_excel():
211
- assert converter.get_questions("test_data/empty.xlsx").shape[0] == 0
212
-
213
-
214
- def test_get_questions_file():
215
- assert converter.get_questions("test_data/input.xlsx").shape[0] == 2
216
-
217
-
218
- def test_get_questions_directory():
219
- assert converter.get_questions("test_data/").shape[0] == 2
220
-
221
-
222
- def test_make_anki():
223
- df = converter.get_questions("test_data/input.xlsx")
224
- converter.make_anki(df, "test_data/", "test")
225
- # Check if output file exists
226
- assert os.path.exists("test_data/anki.apkg") is True