-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
93 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# packaging for flaskapp.tests |
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,53 @@ | ||
import pytest | ||
import os | ||
import collections | ||
|
||
from coursecake.flaskapp import create_app | ||
from coursecake.flaskapp import db | ||
from coursecake.flaskapp.admin import updates | ||
|
||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
app = create_app({"TESTING": True}) | ||
|
||
context = app.app_context() | ||
context.push() | ||
|
||
with app.test_client() as client: | ||
yield client | ||
|
||
|
||
context.pop() | ||
|
||
|
||
def testHome(client): | ||
response = client.get("/") | ||
assert response.status_code == 200 | ||
|
||
|
||
|
||
def testHello(client): | ||
response = client.get("/api/v1/hello/") | ||
assert response.status_code == 200 | ||
assert response.json["hello"] == "world" | ||
|
||
|
||
def testReloadDb(client): | ||
''' | ||
Would test routes, but admin token is subject to change | ||
''' | ||
updates.reloadAllModels() | ||
courses = updates.updateAllUciCourses() | ||
|
||
assert len(courses) > 100 | ||
|
||
|
||
def testCoursesSearch(client): | ||
university = "uci" | ||
headers = {"department": "compsci"} | ||
response = client.get(f"/api/v1/courses/search/{university}", headers=headers) | ||
|
||
assert response.status_code == 200 | ||
assert len(response.json["courses"]) > 10 |
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
# packaging for scrapers.tests | ||
|
||
|
||
import pytest | ||
|
||
from coursecake.scrapers.course_scraper import CourseScraper | ||
|
||
def testFunc(): | ||
assert True | ||
|
||
|
||
|
||
def testGetCoursesDept(): | ||
scraper = CourseScraper().getUciScraper() | ||
courses = scraper.getCourses({"department":"compsci"}) | ||
assert len(courses) > 10 | ||
|
||
|
||
def testGetCoursesCode(): | ||
scraper = CourseScraper().getUciScraper() | ||
courses = scraper.getCourses({"code": "30000-32000"}) | ||
assert len(courses) > 10 | ||
|
||
|
||
def testGetAllCourses(): | ||
scraper = CourseScraper().getUciScraper() | ||
courses = scraper.scrape() | ||
|
||
assert len(courses) > 1000 |