Skip to content

Commit fdace0b

Browse files
committed
Merge branch 'dev-tests' into dev-tests-cleanup
2 parents e81d5ce + 9f1e2c4 commit fdace0b

15 files changed

Lines changed: 8300 additions & 8 deletions

tests/conftest.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ def enable_filepath_feature(monkeypatch):
5858
monkeypatch.delenv(FILEPATH_FEATURE_SWITCH, raising=True)
5959

6060

61+
@pytest.fixture(scope="session")
62+
def db_creds_test() -> Dict:
63+
return dict(
64+
host=os.getenv("DJ_TEST_HOST", "fakeservices.datajoint.io"),
65+
user=os.getenv("DJ_TEST_USER", "datajoint"),
66+
password=os.getenv("DJ_TEST_PASSWORD", "datajoint"),
67+
)
68+
69+
6170
@pytest.fixture(scope="session")
6271
def db_creds_root() -> Dict:
6372
return dict(
@@ -144,7 +153,7 @@ def connection_root(connection_root_bare, prefix):
144153

145154

146155
@pytest.fixture(scope="session")
147-
def connection_test(connection_root, prefix):
156+
def connection_test(connection_root, prefix, db_creds_test):
148157
"""Test user database connection."""
149158
database = f"{prefix}%%"
150159
credentials = dict(
@@ -159,14 +168,14 @@ def connection_test(connection_root, prefix):
159168
# create user if necessary on mysql8
160169
connection_root.query(
161170
f"""
162-
CREATE USER IF NOT EXISTS '{credentials["user"]}'@'%%'
163-
IDENTIFIED BY '{credentials["password"]}';
171+
CREATE USER IF NOT EXISTS '{db_creds_test["user"]}'@'%%'
172+
IDENTIFIED BY '{db_creds_test["password"]}';
164173
"""
165174
)
166175
connection_root.query(
167176
f"""
168177
GRANT {permission} ON `{database}`.*
169-
TO '{credentials["user"]}'@'%%';
178+
TO '{db_creds_test["user"]}'@'%%';
170179
"""
171180
)
172181
else:
@@ -175,14 +184,14 @@ def connection_test(connection_root, prefix):
175184
connection_root.query(
176185
f"""
177186
GRANT {permission} ON `{database}`.*
178-
TO '{credentials["user"]}'@'%%'
179-
IDENTIFIED BY '{credentials["password"]}';
187+
TO '{db_creds_test["user"]}'@'%%'
188+
IDENTIFIED BY '{db_creds_test["password"]}';
180189
"""
181190
)
182191

183-
connection = dj.Connection(**credentials)
192+
connection = dj.Connection(**db_creds_test)
184193
yield connection
185-
connection_root.query(f"""DROP USER `{credentials["user"]}`""")
194+
connection_root.query(f"""DROP USER `{db_creds_test["user"]}`""")
186195
connection.close()
187196

188197

tests/data/Course.csv

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
dept,course,course_name,credits
2+
BIOL,1006,World of Dinosaurs,3.0
3+
BIOL,1010,Biology in the 21st Century,3.0
4+
BIOL,1030,Human Biology,3.0
5+
BIOL,1210,Principles of Biology,4.0
6+
BIOL,2010,Evolution & Diversity of Life,3.0
7+
BIOL,2020,Principles of Cell Biology,3.0
8+
BIOL,2021,Principles of Cell Science,4.0
9+
BIOL,2030,Principles of Genetics,3.0
10+
BIOL,2210,Human Genetics,3.0
11+
BIOL,2325,Human Anatomy,4.0
12+
BIOL,2330,Plants & Society,3.0
13+
BIOL,2355,Field Botany,2.0
14+
BIOL,2420,Human Physiology,4.0
15+
CS,1030,Foundations of Computer Science,3.0
16+
CS,1410,Introduction to Object-Oriented Programming,4.0
17+
CS,2100,Discrete Structures,3.0
18+
CS,2420,Introduction to Algorithms & Data Structures,4.0
19+
CS,3100,Models of Computation,3.0
20+
CS,3200,Introduction to Scientific Computing,3.0
21+
CS,3500,Software Practice,4.0
22+
CS,3505,Software Practice II,3.0
23+
CS,3810,Computer Organization,4.0
24+
CS,4000,Senior Capstone Project - Design Phase,3.0
25+
CS,4150,Algorithms,3.0
26+
CS,4400,Computer Systems,4.0
27+
CS,4500,Senior Capstone Project,3.0
28+
CS,4940,Undergraduate Research,3.0
29+
CS,4970,Computer Science Bachelors Thesis,3.0
30+
MATH,1210,Calculus I,4.0
31+
MATH,1220,Calculus II,4.0
32+
MATH,1250,Calculus for AP Students I,4.0
33+
MATH,1260,Calculus for AP Students II,4.0
34+
MATH,2210,Calculus III,3.0
35+
MATH,2270,Linear Algebra,4.0
36+
MATH,2280,Introduction to Differential Equations,4.0
37+
MATH,3210,Foundations of Analysis I,4.0
38+
MATH,3220,Foundations of Analysis II,4.0
39+
PHYS,2040,Classical Theoretical Physics II,4.0
40+
PHYS,2060,Quantum Mechanics,3.0
41+
PHYS,2100,General Relativity and Cosmology,3.0
42+
PHYS,2140,Statistical Mechanics,4.0
43+
PHYS,2210,Physics for Scientists and Engineers I,4.0
44+
PHYS,2220,Physics for Scientists and Engineers II,4.0
45+
PHYS,3210,Physics for Scientists I (Honors),4.0
46+
PHYS,3220,Physics for Scientists II (Honors),4.0

tests/data/CurrentTerm.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
omega,term_year,term
2+
1,2020,Fall

tests/data/Department.csv

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dept,dept_name,dept_address,dept_phone
2+
BIOL,Life Sciences,"931 Eric Trail Suite 331
3+
Lake Scott, CT 53527",(238)497-9162x0223
4+
CS,Computer Science,"0104 Santos Hill Apt. 497
5+
Michelleland, MT 94473",3828723244
6+
MATH,Mathematics,"8358 Bryan Ports
7+
Lake Matthew, SC 36983",+1-461-767-9298x842
8+
PHYS,Physics,"7744 Haley Meadows Suite 661
9+
Lake Eddie, CT 51544",4097052774

0 commit comments

Comments
 (0)