forked from Cal-CS-61A-Staff/seating
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up Db Seeding Fixture & Increase Test Coverage (#16)
- Loading branch information
Showing
25 changed files
with
400 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ safety==1.10.3 | |
pip-audit==2.6.1 | ||
selenium==4.14.0 | ||
responses==0.23.3 | ||
flask-fixtures==0.3.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[run] | ||
branch = True | ||
source = server | ||
parallel = True | ||
concurrency = | ||
multiprocessing | ||
thread | ||
|
||
[data] | ||
parallel = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from selenium.webdriver.common.by import By | ||
|
||
|
||
def test_student_can_see_offerings(get_authed_driver, seeded_db): | ||
driver = get_authed_driver("234567") | ||
offering_btns = driver.find_elements(By.CSS_SELECTOR, ".mdl-list__item-primary-content") | ||
for btn in offering_btns: | ||
if "Introduction to Software Engineering" in btn.text: | ||
break | ||
else: | ||
assert False | ||
|
||
|
||
def test_student_can_see_exam(get_authed_driver, seeded_db): | ||
driver = get_authed_driver("234567") | ||
offering_btns = driver.find_elements(By.CSS_SELECTOR, ".mdl-list__item-primary-content") | ||
for btn in offering_btns: | ||
if "Introduction to Software Engineering" in btn.text: | ||
btn.click() | ||
break | ||
else: | ||
assert False | ||
exam_btn = driver.find_element(By.CSS_SELECTOR, ".mdl-list__item-primary-content") | ||
assert "Midterm 1" in exam_btn.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from selenium.webdriver.common.by import By | ||
|
||
|
||
def test_ta_can_see_offerings(get_authed_driver, seeded_db): | ||
driver = get_authed_driver("123456") | ||
first_offering_btn = driver.find_element(By.CSS_SELECTOR, ".mdl-list__item-primary-content") | ||
assert "Introduction to Software Engineering" in first_offering_btn.text | ||
|
||
|
||
def test_ta_can_see_exam(get_authed_driver, seeded_db): | ||
driver = get_authed_driver("123456") | ||
first_offering_btn = driver.find_element(By.CSS_SELECTOR, ".mdl-list__item-primary-content") | ||
first_offering_btn.click() | ||
exam_btn = driver.find_element(By.CSS_SELECTOR, ".mdl-list__item-primary-content") | ||
assert "Midterm 1" in exam_btn.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from server import app | ||
from server.models import db | ||
|
||
|
||
def seed_db(): | ||
import flask_fixtures as ff | ||
import os | ||
seed_dir_paths = [os.path.join(app.config.get('BASE_DIR'), d) | ||
for d in app.config.get('FIXTURES_DIRS')] | ||
seed_files_names = [] | ||
seed_file_formats = set(['.yaml', '.yml', '.json']) | ||
|
||
for d in seed_dir_paths: | ||
for file in os.listdir(d): | ||
if not any([file.endswith(form) for form in seed_file_formats]): | ||
continue | ||
seed_files_names.append(file) | ||
|
||
for filename in seed_files_names: | ||
ff.load_fixtures_from_file(db, filename, seed_dir_paths) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"model": "server.models.Exam", | ||
"records": [ | ||
{ | ||
"id": 1, | ||
"offering_canvas_id": "1234567", | ||
"name": "midterm1", | ||
"display_name": "Midterm 1", | ||
"is_active": true | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.