Skip to content

Commit

Permalink
Merge a7e0195 into e512c0d
Browse files Browse the repository at this point in the history
  • Loading branch information
tisuela committed Aug 21, 2020
2 parents e512c0d + a7e0195 commit 3245209
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest and submit to Coveralls
run: |
coverage run --source=coursecake -m pytest coursecake/scrapers/tests/test.py
coverage run --source=coursecake -m pytest --pyargs coursecake
coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 7 additions & 3 deletions coursecake/flaskapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ def create_app(test_config=None):

app.config.from_object(Config)

# bind monitoring
dashboard.config.init_from(envvar='FLASK_MONITORING_DASHBOARD_CONFIG')
dashboard.bind(app)
if (test_config == None):
# bind monitoring if not testing
dashboard.config.init_from(envvar='FLASK_MONITORING_DASHBOARD_CONFIG')
dashboard.bind(app)
else:
# set up testing
pass


# initialize database
Expand Down
2 changes: 2 additions & 0 deletions coursecake/flaskapp/admin/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def updateAllUciCourses():

db.session.commit()

return courses


def reloadCoursesModel():
Courses.__table__.drop(db.engine)
Expand Down
1 change: 1 addition & 0 deletions coursecake/flaskapp/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# packaging for flaskapp.tests
53 changes: 53 additions & 0 deletions coursecake/flaskapp/tests/test_flaskapp.py
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
16 changes: 0 additions & 16 deletions coursecake/scrapers/tests/test.py

This file was deleted.

29 changes: 29 additions & 0 deletions coursecake/scrapers/tests/test_scrapers.py
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

0 comments on commit 3245209

Please sign in to comment.