def test__cat_nap__satisfying_nap(mocker):
    mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
    # how to test: test for called_with value:
    # mock_sleep.return_value = 20
    # assert mock_sleep.called_with(20*60)
    # assert mock_sleep.call_args(20*60)
    catactivities.cat_nap(20 * 60)
    mock_sleep.assert_called_with(20 * 60)
def test__cat_nap__satisfying_nap(mocker):
    mock_time = mocker.patch.object(time, "sleep", autospec=True)
    catactivities.cat_nap(5*60)
    mock_time.assert_called_once_with(5*60)
def test__cat_nap__not_satisfying(mocker):
    mocker.patch.object(time, "sleep", autospec=True)
    with pytest.raises(catactivities.NapWillNotBeSatisfying):
        catactivities.cat_nap(5)
Beispiel #4
0
def test__cat_nap__satisfying_nap(mocker):
    mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
    catactivities.cat_nap(500)
    mock_sleep.assert_called_with(500)
Beispiel #5
0
def test__cat_nap__not_satisfying(mocker):
    mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
    with pytest.raises(catactivities.NapWillNotBeSatisfying):
        catactivities.cat_nap(5)
    assert mock_sleep.call_count == 0
def test__cat_nap__not_satisfying(sleep):
    with pytest.raises(catactivities.NapWillNotBeSatisfying):
        catactivities.cat_nap(15)
    assert sleep.call_count == 0
def test__cat_nap__satisfying_nap(sleep):
    catactivities.cat_nap(300)
    sleep.assert_called_with(300)
def test__cat_nap__satisfying_nap(mocker):
    mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
    sufficient_sleep_length = catactivities.LENGTH_OF_SATISFYING_NAP + 1
    catactivities.cat_nap(sufficient_sleep_length)
    mock_sleep.assert_called_with(sufficient_sleep_length)
def test__cat_nap__not_satisfying(mocker):
    mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
    insufficient_sleep_length = catactivities.LENGTH_OF_SATISFYING_NAP - 1
    with pytest.raises(catactivities.NapWillNotBeSatisfying):
        catactivities.cat_nap(insufficient_sleep_length)
        assert mock_sleep.called
Beispiel #10
0
def test__cat_nap__not_satisfying(sleep):
    with pytest.raises(catactivities.NapWillNotBeSatisfying):
        catactivities.cat_nap(299)
    assert not time.sleep.called
Beispiel #11
0
def test__cat_nap__satisfying_nap(mocker):
    cat_nap_length = 1000
    mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
    catactivities.cat_nap(cat_nap_length)
    mock_sleep.assert_called_with(cat_nap_length)
Beispiel #12
0
def test__cat_nap__not_satisfying(mocker):
    cat_nap_length = 30
    with pytest.raises(catactivities.NapWillNotBeSatisfying):
        catactivities.cat_nap(cat_nap_length)
Beispiel #13
0
def test__cat_nap__not_satisfying():
    with mock.patch.object(time, "sleep") as sleep:
        with pytest.raises(catactivities.NapWillNotBeSatisfying):
            catactivities.cat_nap(5)
        assert sleep.call_count == 0
Beispiel #14
0
def test__cat_nap__satisfying_nap():
    with mock.patch.object(time, "sleep") as sleep:
        catactivities.cat_nap(500)
        sleep.assert_called_with(500)
Beispiel #15
0
def test__cat_nap__not_satisfying(sleep):
    with pytest.raises(catactivities.NapWillNotBeSatisfying):
        catactivities.cat_nap(2)