File: test_create_agent_group.py

package info (click to toggle)
python-gvm 26.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,132 kB
  • sloc: python: 44,662; makefile: 18
file content (40 lines) | stat: -rw-r--r-- 1,386 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# SPDX-FileCopyrightText: 2025 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later

from gvm.errors import RequiredArgument


class GmpCreateAgentGroupTestMixin:
    def test_create_agent_group(self):
        self.gmp.create_agent_group(
            name="ExampleGroup",
            agent_ids=["agent-1", "agent-2"],
            comment="Sample comment",
        )

        self.connection.send.has_been_called_with(
            b"<create_agent_group>"
            b"<name>ExampleGroup</name>"
            b"<comment>Sample comment</comment>"
            b'<agents><agent id="agent-1"/><agent id="agent-2"/></agents>'
            b"</create_agent_group>"
        )

    def test_create_agent_group_without_name(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_agent_group(name="", agent_ids=["agent-1"])

    def test_create_agent_group_without_agents(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_agent_group(name="Group", agent_ids=[])

    def test_create_agent_group_without_comment(self):
        self.gmp.create_agent_group(name="GroupX", agent_ids=["a1", "a2"])

        self.connection.send.has_been_called_with(
            b"<create_agent_group>"
            b"<name>GroupX</name>"
            b'<agents><agent id="a1"/><agent id="a2"/></agents>'
            b"</create_agent_group>"
        )