Skip to content

Tests: Add system tests for groupadd in test_groupadd.py - #1693

Open
asakure wants to merge 3 commits into
shadow-maint:masterfrom
asakure:system_tests_groupadd_22_23_24
Open

Tests: Add system tests for groupadd in test_groupadd.py#1693
asakure wants to merge 3 commits into
shadow-maint:masterfrom
asakure:system_tests_groupadd_22_23_24

Conversation

@asakure

@asakure asakure commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Add system tests for groupadd in test_groupadd.py for
existing bash tests with numbering 22, 23, 24.

@asakure
asakure marked this pull request as ready for review July 23, 2026 15:01
This is Python transformation of the test located in
`tests/grouptools/groupadd/22_groupadd_usage/groupadd.test`
which checks that `groupadd` command shows usage with -h option.

Signed-off-by: Akshay Sakure <asakure@redhat.com>
This is Python transformation of the test located in
`tests/grouptools/groupadd/23_groupadd_no_groups/groupadd.test`
which checks that `groupadd` fails when no groupname is
mentioned. It also fixes an issue in shadow.py file to handle
empty args in _parse_args and groupadd.

Signed-off-by: Akshay Sakure <asakure@redhat.com>
This is Python transformation of the test located in
`tests/grouptools/groupadd/24_groupadd_2_groups/groupadd.test`
which checks that `groupadd` command fails when two groupnames
are mentioned. It also parametrize python tests 23 and 24 into
single test.

Signed-off-by: Akshay Sakure <asakure@redhat.com>
@asakure
asakure force-pushed the system_tests_groupadd_22_23_24 branch from cbb8850 to d010ea7 Compare August 26, 2026 06:02
:customerscenario: False
"""
result = shadow.groupadd("-h")
assert result.rc == 0, f"Expected return code 0(success), got {result.rc}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You could add additional asserts checking specific parts of the output

Comment on lines 50 to 234
@@ -230,7 +230,7 @@ def groupadd(self, *args) -> ProcessResult:
"""
args_dict = self._parse_args(args)
self.logger.info(f'Creating group "{args_dict["name"]}" on {self.host.hostname}')
cmd = self.host.conn.run("groupadd " + args[0], log_level=ProcessLogLevel.Error)
cmd = self.host.conn.run("groupadd " + (args[0] if args else ""), log_level=ProcessLogLevel.Error)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Move the changes in this file to a separate commit

"""
with pytest.raises(ProcessError) as exc_info:
shadow.groupadd()
shadow.groupadd(f"{args}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You don't need to prepend the f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants