Comments (9)
@Rahi374
This is my code for testing each subject.
# Tests that all subjects properly return their course details
for t in self.TERMS:
for s in self.SUBJECTS:
try:
results = course.get_courses(term=t, subject=s)
except ValueError:
self.fail(msg="Term {} and/or Subject {} is not valid.".format(t, s))
for result in results:
self.assertIn(t, result['term'])
self.assertIn(s, result['subject'])
When I started to do some initial testing (with the code above) I found that certain subjects
you have defined are not really subject but actually programs which throw the test off. Some of these programs
include ['BCC', 'CGSDAY', 'GSWS', 'CGSSAT']
. This is mainly because the courses in each program
don't take the program code but instead, they use various subject codes.
So, for example, a subject
like BIOSC
has all its courses with the BIOSC
subject code.
As shown here
But for a program
like GSWS
it has courses with various codes such as ['ADMPS', 'AFRCNA', 'ANTH', 'ENGCMP', 'ENGLIT']
As shown here
Even further on a program page, it doesn't actually show all courses unless specified.
- results-subjspecial.asp?TERM=2171&SUBJ=GSWS : First 15 results
- results-subjspeciala.asp?TERM=2171&SUBJ=GSWS : All Results
So there need to be a couple of changes to get_courses()
in order for this to work properly
So this is what I was talking about when I said the test might get a little more complicated because of this. I think the solution to this is to just test all the subjects
and then just test to see if the programs
give off courses.
Also, can you tell me which version(s) of python this library supports?
from pittapi.
As seen here, maybe we could look for "No records matched your query." and return an empty list?
from pittapi.
The easiest way to prevent this is to have a list of all valid subjects and check the subject entered against it. The issue with @RitwikGupta solution is that "No records matched your query."
always occurs when an invalid subject value is entered. As shown by this.
from pittapi.
@Rahi374 I took a look at your unit test and it only addresses all correct scenarios, I'm writing up a slightly different version that includes your code but with fake subjects and term to make sure that it errors out properly.
Update: Looks like things might get a little more complicated since your test only tests subject there are many failures do to using program code. I'm adding another part to the test where it will make sure that get_courses()
with properly also get program courses.
from pittapi.
@azharichenko No I haven't yet pushed my unit tests that test this.
from pittapi.
Here.
I guess I do also use the length of the course_list to test that retrieve_from_url though...
from pittapi.
but with fake subjects and term to make sure that it errors out properly.
Yeah that's probably a better idea. I hadn't gotten there yet.
since your test only tests subject there are many failures do to using program code. I'm adding another part to the test where it will make sure that get_courses() with properly also get program courses.
What do you mean?
from pittapi.
@azharichenko I targeted Python 2.7 when creating it, but over time we've ensured it fully supports Python 3 as well (check with python3 -m py_compile pittAPI.py
). However, this puts us at a crossroads where we can't use things like asyncio
and more to maintain the 2.7 support.
from pittapi.
Closed with #43
from pittapi.
Related Issues (20)
- Use LaundryView's JSON API instead of BeautifulSoup HOT 2
- Issues with Shuttle API's get_vehicle_route_stop_estimates HOT 1
- IndexError when getting extra details for section HOT 1
- Exception of course caused by the edge case HOT 3
- Courses HTML Page is updated so scraping is incorrect HOT 1
- Making the package name lowercase HOT 1
- Moving docs onto readthedocs
- Switch from unittest to pytest
- Fixing up the docstrings in sports api
- Adding typing information into sports api
- Looking over the data results of sports api
- People api seems to be dead.
- Any API using m.pitt.edu are dead, new scrapers needed!
- make PittAPI actually an API HOT 4
- Unit tests should be hermetic HOT 1
- ValueError when using BeautifulSoup in lab.py HOT 18
- Create a Library API HOT 1
- People API is broken HOT 2
- README.md issues HOT 4
- As of this term, the Course API is broken HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pittapi.