コード例 #1
0
 def test_TypeError(appt1, appt2):
     """Test TypeError raising during Appointment._is_conflicting()."""
     with pytest.raises(TypeError) as excinfo:
         Appointment._is_conflicting(appt1, appt2)
コード例 #2
0
def test__is_conflicting():
    """Test Appointment._is_conflicting() static function."""
    def test_TypeError(appt1, appt2):
        """Test TypeError raising during Appointment._is_conflicting()."""
        with pytest.raises(TypeError) as excinfo:
            Appointment._is_conflicting(appt1, appt2)

    name, day, start, end, participants = "a", "Friday", "1:00pm", "2:00pm", [1]
    A1 = Appointment(name, day, start, end, participants)
    A2 = Appointment('b', day, start, end, participants)
    A3 = Appointment(name, "Saturday", start, end, participants)
    A4 = Appointment(name, day, "11:00am", end, participants)
    A5 = Appointment(name, day, start, "3:00pm", participants)
    A6 = Appointment(name, day, start, end, [2])
    A7 = Appointment(name, day, start, end, [1,2])
    A8 = Appointment(name, day, "11:00am", "3:00pm", participants)
    
    test_TypeError(A1, None)
    test_TypeError(None, A1)
    #appointment does not conflict with itself
    assert not Appointment._is_conflicting(A1, A1)
    assert Appointment._is_conflicting(A1, A2)
    assert Appointment._is_conflicting(A2, A1)
    assert not Appointment._is_conflicting(A1, A3)
    assert not Appointment._is_conflicting(A3, A1)
    assert Appointment._is_conflicting(A1, A4)
    assert Appointment._is_conflicting(A4, A1)
    assert Appointment._is_conflicting(A1, A5)
    assert Appointment._is_conflicting(A5, A1)
    assert not Appointment._is_conflicting(A1, A6)
    assert not Appointment._is_conflicting(A6, A1)
    assert Appointment._is_conflicting(A1, A7)
    assert Appointment._is_conflicting(A7, A1)
    assert Appointment._is_conflicting(A1, A8)
    assert Appointment._is_conflicting(A8, A1)