Skip to content

Instantly share code, notes, and snippets.

@sualeh
Created September 19, 2022 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sualeh/664103c429a71e7a9d23c77cb16552ba to your computer and use it in GitHub Desktop.
Save sualeh/664103c429a71e7a9d23c77cb16552ba to your computer and use it in GitHub Desktop.
COMP-880 Lab 3 Grading Tests
"""Tests for lab module."""
import pytest
import schedule
def test_schedule_0():
"""Tests an argument of None, and ensures that no error occurs."""
sch = schedule.Schedule(None, ['Math'])
classes: list = sch.classes_for('Mon')
for day in ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']:
assert sch.classes_for(day) == ['Free day']
def test_schedule_1():
"""Tests an argument of None, and ensures that no error occurs."""
with pytest.raises(TypeError):
sch = schedule.Schedule(['Mon'], False)
def test_schedule_2():
"""Tests happy path."""
sch = schedule.Schedule(['Tue', 'Thu'], [['Algebra', 'Chemistry'], ['French']])
assert sch.classes_for('Tue') == ['Algebra', 'Chemistry']
assert sch.classes_for('Thu') == ['French']
assert sch.classes_for('Sun') == ['Free day']
assert sch.classes_for('Holiday') == ['No such day']
def test_schedule_3():
"""Tests make_schedule does overrides old schedule."""
sch = schedule.Schedule(['Tue', 'Thu'], [['Algebra', 'Chemistry'], ['French']])
sch.make_schedule(['Mon'], [['Biology']])
assert sch.classes_for('Mon') == ['Biology']
assert sch.classes_for('Tue') == ['Free day']
assert sch.classes_for('Thu') == ['Free day']
assert sch.classes_for('Sun') == ['Free day']
assert sch.classes_for('Holiday') == ['No such day']
def test_schedule_4():
"""Tests an argument of a list with positive and negative elements."""
sch = schedule.Schedule(['Tue', 'Thu'], [['Algebra', 'Chemistry'], ['French']])
print(str(sch))
assert str(sch) == """Tue: Algebra, Chemistry
Thu: French
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment