Beispiel #1
0
def post_username(context):
    """ Test calling the post_username method """
    with mock_request(context, HtmlMock().paychex_start):
        mock_obj = ContextJsonMock(context)
        with mock_request(context, mock_obj.paychex_security_image):
            try:
                context.paychex.post_username()
            except PychexSecurityImageMismatchError:
                context.exceptions.append(sys.exc_info()[1])
Beispiel #2
0
def authorize(context, input_mock, getpass_mock, image_open_mock):
    """ Test running the authorize method """
    with mock_login_requests(context):
        with mock_request(context, FileMock().security_image_gif):
            mock_func = ContextXmlMock(context).paychex_account_data
            with mock_request(context, mock_func):
                getpass_mock.return_value = context.password
                input_mock.return_value = context.security_answer
                arguments = {
                    'authorize': True,
                    '--config': context.config_file,
                    '<username>': context.username
                }
                pychex_cli = PychexCli(arguments)
                input_mock.assert_called_once_with(
                    'Is this your security image (Y/n)? ')
                assert image_open_mock.call_count == 1
                if context.security_answer in ['yes', 'y', 'ye', '']:
                    getpass_mock.assert_called_once_with(
                        'Password (input hidden): ')
                    assert pychex_cli.username == context.username
Beispiel #3
0
def _get_bol_username(context, has_bol=True):
    """
    Utility method to call get_bol_username with or without a Benefits
    OnLine account
    """
    context.has_bol = has_bol
    with mock_login_requests(context):
        with mock_request(context,
                          ContextXmlMock(context).paychex_account_data):
            try:
                return context.paychex.get_bol_username()
            except (PychexNoBolUsernameError, PychexUnauthenticatedError):
                context.exceptions.append(sys.exc_info()[1])
Beispiel #4
0
def run_account_summary(context, json=False):
    # Make sure the password check passes in the paychex_login mock
    context.paychex = MagicMock()
    context.paychex.password = context.password
    # Reset the stdout capture
    context.stdout_capture.truncate(0)
    context.stdout_capture.seek(0)

    with mock_login_requests(context):
        mock_obj = ContextXmlMock(context)
        with mock_request(context, mock_obj.paychex_account_data):
            with mock_benefits_requests(context):
                arguments = {
                    'authorize': False,
                    'account_summary': True,
                    '--config': context.config_file,
                    '--json': json
                }
                try:
                    PychexCli(arguments)
                except Exception:
                    assert False, 'Exception: %s' % sys.exc_info()[1]
Beispiel #5
0
def initialize_session(context):
    """ Test calling the initialize_session method """
    with mock_request(context, HtmlMock().paychex_start_url):
        context.paychex.initialize_session()