Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user factory function for using in tests #109

Merged
merged 2 commits into from
Aug 16, 2022
Merged

Add user factory function for using in tests #109

merged 2 commits into from
Aug 16, 2022

Conversation

x00Pavel
Copy link
Member

Add user factory function that would be used in tests. This factory would generate (load from JSON) the user with requires a username and returns a new instance of the BaseUser object.

Code usage example:

@pytest.mark.parametrize("user", [user_factory("local-user"), user_factory("ipa-user")], scope="session")  # <-------------------------
def test_su_login_with_sc(user, user_shell):
    with Authselect(required=False):
        with user.card(insert=True):
            cmd = f'su {user.username} -c "whoami"'
            user_shell.sendline(cmd)
            user_shell.expect(f"PIN for {user.username}:")
            user_shell.sendline(user.pin)
            user_shell.expect(user.username)

@x00Pavel x00Pavel added the enhancement New feature or request label Aug 15, 2022
@x00Pavel x00Pavel requested a review from ep69 August 15, 2022 14:01
@x00Pavel x00Pavel self-assigned this Aug 15, 2022
Copy link
Member

@ep69 ep69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My biggest concern is that we are adding a function that is not being used. I understand it is probably meant for tests that are in separate repository, but we should at least add a unit test.

SCAutolib/utils.py Outdated Show resolved Hide resolved
SCAutolib/utils.py Show resolved Hide resolved
@x00Pavel
Copy link
Member Author

Will add unit test.

@x00Pavel x00Pavel requested a review from ep69 August 15, 2022 14:21
@x00Pavel x00Pavel merged commit f431968 into V2 Aug 16, 2022
@x00Pavel x00Pavel deleted the V2-user-factory branch August 16, 2022 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants