Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Minor fixes in models_tests & grades model
Browse files Browse the repository at this point in the history
Changed instructor_performance return to specify that Dict value can be a float or int

Rest of commit is minor comment fixes
  • Loading branch information
gannonprudhomme committed Mar 22, 2020
1 parent f416d0e commit 256e8cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
10 changes: 5 additions & 5 deletions autoscheduler/scraper/models/grades.py
@@ -1,6 +1,6 @@
""" Heavily based off of Good Bull Schedules """

from typing import Dict
from typing import Dict, Union
from django.db import models

class GradeManager(models.Manager):
Expand All @@ -10,12 +10,12 @@ class GradeManager(models.Manager):

def instructor_performance(
self, dept: str, course_num: str, instructor: str
) -> Dict[str, float]:
) -> Dict[str, Union[int, float]]:
""" Aggregates all of the GPA's / sum of each grade type into one object
so we can quickly get how an instructor performed in past sections
for a given course
Returns a dictionary of string-integer, pairs, where str is the attribute
Returns a dictionary of string-integer/float pairs, where str is the attribute
(i.e. gpa), and float is the according value (is an integer for grade counts)
"""

Expand Down Expand Up @@ -51,13 +51,13 @@ class Grades(models.Model):
# Section is the primary key, since one section = one grade distribution
section = models.OneToOneField("Section", on_delete=models.CASCADE, primary_key=True)

# Overrides the default Grades.object member, which allows us
# Overrides the default Grades.objects member, which allows us
# to call Grades.object.instructor_performance
objects = GradeManager()

gpa = models.FloatField()

# Each of these represent many students received the given grade
# Each of these represent how many students received the given grade
# See http://student-rules.tamu.edu/rule10/ for more details
A = models.IntegerField(db_index=True)
B = models.IntegerField(db_index=True)
Expand Down
7 changes: 1 addition & 6 deletions autoscheduler/scraper/tests/models_tests.py
Expand Up @@ -9,10 +9,6 @@
from scraper.models.grades import Grades
from scraper.models.instructor import Instructor

# A lot of these funcitons have to be self in order to be part of the TestCase and thus,
# run, but they don't actually use self in their functions, so silence this error
# pylint: disable=no-self-use

class DepartmentTests(unittest.TestCase):
""" Department model tests """
def test_generate_department_id_does_form(self):
Expand Down Expand Up @@ -46,7 +42,7 @@ def test_generate_meeting_id_returns_correct_id(self):
self.assertEqual(meeting_id, "1234560")

class GradesTests(django.test.TestCase):
""" Tests for Grade model + GradeManager """
""" Tests for Grades model + GradeManager """

def test_instructor_performances_calculates_from_all_terms(self):
""" Tests that instructor performance uses all of the
Expand Down Expand Up @@ -77,7 +73,6 @@ def test_instructor_performances_calculates_from_all_terms(self):
Q=0, X=0),
]

# Save all at once
Grades.objects.bulk_create(grades)

expected = {
Expand Down

0 comments on commit 256e8cf

Please sign in to comment.