Giter Club home page Giter Club logo

Comments (9)

azharichenko avatar azharichenko commented on June 17, 2024 1

@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.

RitwikGupta avatar RitwikGupta commented on June 17, 2024

As seen here, maybe we could look for "No records matched your query." and return an empty list?

from pittapi.

azharichenko avatar azharichenko commented on June 17, 2024

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.

azharichenko avatar azharichenko commented on June 17, 2024

@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.

Rahi374 avatar Rahi374 commented on June 17, 2024

@azharichenko No I haven't yet pushed my unit tests that test this.

from pittapi.

Rahi374 avatar Rahi374 commented on June 17, 2024

Rahi374@40de516

Here.
I guess I do also use the length of the course_list to test that retrieve_from_url though...

from pittapi.

Rahi374 avatar Rahi374 commented on June 17, 2024

@azharichenko

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.

RitwikGupta avatar RitwikGupta commented on June 17, 2024

@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.

RitwikGupta avatar RitwikGupta commented on June 17, 2024

Closed with #43

from pittapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.