コード例 #1
0
def test_check_resources_returns_false_for_weekend_or_holiday(args, date_str):
    holiday = Mock()
    holiday.is_holiday = Mock(return_value=True)

    args['holiday'] = holiday

    date = datetime.strptime(date_str, '%Y-%m-%d')

    pcm = PunchCardManager(args)
    pcm.login_to_paylocity = Mock()

    actual = pcm.check_resources(date)

    pcm.login_to_paylocity.assert_not_called()
    assert actual is False
コード例 #2
0
def test_check_resources_returns_based_on_pto(args, is_pto_day_return):
    pto_mock = Mock()
    pto_mock.is_pto_day = Mock(return_value=is_pto_day_return)

    dash_mock = Mock()
    dash_mock.go_to_pto = Mock(return_value=pto_mock)

    holiday = Mock()
    holiday.is_holiday = Mock(return_value=False)

    args['holiday'] = holiday

    pcm = PunchCardManager(args)
    pcm.login_to_paylocity = Mock(return_value=dash_mock)

    now = Mock()
    now.weekday = Mock(return_value=3)  # Number is arbitrary, but less than 5

    actual = pcm.check_resources(now)

    assert actual is not is_pto_day_return
コード例 #3
0
def test_is_clock_in_day_returns_bool(args, work_day_return, resource_return):
    punch = Mock()
    punch.is_work_day = Mock(return_value=work_day_return)
    punch.update_is_work_day = Mock()

    args['punch'] = punch

    now = datetime.now()

    pcm = PunchCardManager(args)
    pcm.check_resources = Mock(return_value=resource_return)

    actual = pcm.is_clock_in_day(now)

    if work_day_return is None:
        pcm.check_resources.assert_called_once_with(now)
        punch.update_is_work_day.assert_called_once_with(resource_return)
        assert actual is resource_return
    else:
        pcm.check_resources.assert_not_called()
        punch.update_is_work_day.assert_not_called()
        assert actual is work_day_return