File: test_modify_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 (69 lines) | stat: -rw-r--r-- 2,339 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# SPDX-FileCopyrightText: 2025 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later

from gvm.errors import RequiredArgument


class GmpModifyAgentGroupTestMixin:
    def test_modify_agent_group(self):
        self.gmp.modify_agent_group(
            agent_group_id="group-1",
            name="NewName",
            comment="Updated comment",
            agent_ids=["agent-1", "agent-2"],
        )

        self.connection.send.has_been_called_with(
            b'<modify_agent_group agent_group_id="group-1">'
            b"<name>NewName</name>"
            b"<comment>Updated comment</comment>"
            b'<agents><agent id="agent-1"/><agent id="agent-2"/></agents>'
            b"</modify_agent_group>"
        )

    def test_modify_agent_group_without_id(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.modify_agent_group(agent_group_id=None)

    def test_modify_agent_group_without_name(self):
        self.gmp.modify_agent_group(
            agent_group_id="group-1",
            comment="Updated comment",
            agent_ids=["agent-1", "agent-2"],
        )

        self.connection.send.has_been_called_with(
            b'<modify_agent_group agent_group_id="group-1">'
            b"<comment>Updated comment</comment>"
            b'<agents><agent id="agent-1"/><agent id="agent-2"/></agents>'
            b"</modify_agent_group>"
        )

    def test_modify_agent_group_without_comment(self):
        self.gmp.modify_agent_group(
            agent_group_id="group-1",
            name="NewName",
            agent_ids=["agent-1", "agent-2"],
        )

        self.connection.send.has_been_called_with(
            b'<modify_agent_group agent_group_id="group-1">'
            b"<name>NewName</name>"
            b'<agents><agent id="agent-1"/><agent id="agent-2"/></agents>'
            b"</modify_agent_group>"
        )

    def test_modify_agent_group_without_agent_ids(self):
        self.gmp.modify_agent_group(
            agent_group_id="group-1",
            name="NewName",
            comment="Updated comment",
        )

        self.connection.send.has_been_called_with(
            b'<modify_agent_group agent_group_id="group-1">'
            b"<name>NewName</name>"
            b"<comment>Updated comment</comment>"
            b"</modify_agent_group>"
        )