Completed
Push — master ( b1214c...aea294 )
by Björn
28s queued 20s
created

tests.protocols.gmpv208.system.system_reports.test_get_system_reports   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 36
dl 0
loc 78
rs 10
c 0
b 0
f 0
wmc 9

8 Methods

Rating   Name   Duplication   Size   Complexity  
A GmpGetSystemReportsTestMixin.test_get_system_reports_with_name() 0 5 1
A GmpGetSystemReportsTestMixin.test_get_system_reports_with_brief() 0 11 1
A GmpGetSystemReportsTestMixin.test_get_system_reports_with_start_time() 0 5 1
A GmpGetSystemReportsTestMixin.test_get_system_reports_with_end_time() 0 5 1
A GmpGetSystemReportsTestMixin.test_get_system_reports() 0 4 1
A GmpGetSystemReportsTestMixin.test_get_system_reports_with_duration() 0 5 1
A GmpGetSystemReportsTestMixin.test_get_system_reports_with_slave_id() 0 5 1
A GmpGetSystemReportsTestMixin.test_get_system_reports_with_invalid_duration() 0 3 2
1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2018-2021 Greenbone Networks GmbH
3
#
4
# SPDX-License-Identifier: GPL-3.0-or-later
5
#
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
from gvm.errors import InvalidArgument
20
21
22
class GmpGetSystemReportsTestMixin:
23
    def test_get_system_reports(self):
24
        self.gmp.get_system_reports()
25
26
        self.connection.send.has_been_called_with('<get_system_reports/>')
27
28
    def test_get_system_reports_with_name(self):
29
        self.gmp.get_system_reports(name='foo')
30
31
        self.connection.send.has_been_called_with(
32
            '<get_system_reports name="foo"/>'
33
        )
34
35
    def test_get_system_reports_with_slave_id(self):
36
        self.gmp.get_system_reports(slave_id='s1')
37
38
        self.connection.send.has_been_called_with(
39
            '<get_system_reports slave_id="s1"/>'
40
        )
41
42
    def test_get_system_reports_with_brief(self):
43
        self.gmp.get_system_reports(brief=True)
44
45
        self.connection.send.has_been_called_with(
46
            '<get_system_reports brief="1"/>'
47
        )
48
49
        self.gmp.get_system_reports(brief=False)
50
51
        self.connection.send.has_been_called_with(
52
            '<get_system_reports brief="0"/>'
53
        )
54
55
    def test_get_system_reports_with_duration(self):
56
        self.gmp.get_system_reports(duration=3600)
57
58
        self.connection.send.has_been_called_with(
59
            '<get_system_reports duration="3600"/>'
60
        )
61
62
    def test_get_system_reports_with_invalid_duration(self):
63
        with self.assertRaises(InvalidArgument):
64
            self.gmp.get_system_reports(duration='')
65
66
    def test_get_system_reports_with_start_time(self):
67
        self.gmp.get_system_reports(start_time='01-01-2019')
68
69
        self.connection.send.has_been_called_with(
70
            '<get_system_reports start_time="01-01-2019"/>'
71
        )
72
73
    def test_get_system_reports_with_end_time(self):
74
        self.gmp.get_system_reports(end_time='01-01-2019')
75
76
        self.connection.send.has_been_called_with(
77
            '<get_system_reports end_time="01-01-2019"/>'
78
        )
79