Changeset 1801:70f6c1457158


Ignore:
Timestamp:
Jun 10, 2019, 10:11:26 PM (3 months ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Use `ScriptedSession` in `test_assert_valid_time_shift`
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/test_host.py

    r1800 r1801  
    621621    def test_assert_valid_time_shift(self):
    622622        """Test time shift sanity checks."""
    623         host = test_base.ftp_host_factory(session_factory=TimeShiftMockSession)
    624         # Use private bound method.
    625         assert_time_shift = host._FTPHost__assert_valid_time_shift
    626         # Valid time shifts
    627         test_data = [23*3600, -23*3600, 3600+30, -3600+30]
    628         for time_shift in test_data:
    629             assert assert_time_shift(time_shift) is None
    630         # Invalid time shift (exceeds one day)
    631         with pytest.raises(ftputil.error.TimeShiftError):
    632             assert_time_shift(25*3600)
    633         with pytest.raises(ftputil.error.TimeShiftError):
    634             assert_time_shift(-25*3600)
    635         # Invalid time shift (too large deviation from 15-minute units
    636         # is unacceptable)
    637         with pytest.raises(ftputil.error.TimeShiftError):
    638             assert_time_shift(8*60)
    639         with pytest.raises(ftputil.error.TimeShiftError):
    640             assert_time_shift(-3600-8*60)
     623        Call = scripted_session.Call
     624        script = [
     625          Call("__init__"),
     626          Call(method_name="pwd", result="/"),
     627          Call(method_name="close"),
     628        ]
     629        multisession_factory = scripted_session.factory(script)
     630        with test_base.ftp_host_factory(multisession_factory) as host:
     631            # Use private bound method.
     632            assert_time_shift = host._FTPHost__assert_valid_time_shift
     633            # Valid time shifts
     634            test_data = [23*3600, -23*3600, 3600+30, -3600+30]
     635            for time_shift in test_data:
     636                assert assert_time_shift(time_shift) is None
     637            # Invalid time shift (exceeds one day)
     638            with pytest.raises(ftputil.error.TimeShiftError):
     639                assert_time_shift(25*3600)
     640            with pytest.raises(ftputil.error.TimeShiftError):
     641                assert_time_shift(-25*3600)
     642            # Invalid time shift (too large deviation from 15-minute units
     643            # is unacceptable)
     644            with pytest.raises(ftputil.error.TimeShiftError):
     645                assert_time_shift(8*60)
     646            with pytest.raises(ftputil.error.TimeShiftError):
     647                assert_time_shift(-3600-8*60)
    641648
    642649    def test_synchronize_times(self):
Note: See TracChangeset for help on using the changeset viewer.