Completed
Push — master ( 42f470...4e3fbe )
by
unknown
25s queued 10s
created

tests.protocols.gmpv7.test_get_tasks   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 75
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A GmpGetTaskTestCase.test_get_tasks_with_schedules_only() 0 5 1
A GmpGetTaskTestCase.test_get_tasks_from_trash() 0 5 1
A GmpGetTaskTestCase.test_get_tasks_with_filter() 0 5 1
A GmpGetTaskTestCase.setUp() 0 3 1
A GmpGetTaskTestCase.test_get_tasks_simple() 0 5 1
A GmpGetTaskTestCase.test_get_tasks_with_details() 0 5 1
A GmpGetTaskTestCase.test_get_tasks_with_filter_id() 0 5 1
A GmpGetTaskTestCase.test_get_tasks_without_details() 0 5 1
1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2018 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
import unittest
20
21
from gvm.protocols.gmpv7 import Gmp
22
23
from .. import MockConnection
24
25
class GmpGetTaskTestCase(unittest.TestCase):
26
27
    def setUp(self):
28
        self.connection = MockConnection()
29
        self.gmp = Gmp(self.connection)
30
31
    def test_get_tasks_simple(self):
32
        self.gmp.get_tasks()
33
34
        self.connection.send.has_been_called_with(
35
            '<get_tasks/>')
36
    def test_get_tasks_with_filter(self):
37
        self.gmp.get_tasks(filter='name=foo')
38
39
        self.connection.send.has_been_called_with(
40
            '<get_tasks filter="name=foo"/>')
41
42
    def test_get_tasks_with_filter_id(self):
43
        self.gmp.get_tasks(filter_id='f1')
44
45
        self.connection.send.has_been_called_with(
46
            '<get_tasks filt_id="f1"/>')
47
48
    def test_get_tasks_from_trash(self):
49
        self.gmp.get_tasks(trash=True)
50
51
        self.connection.send.has_been_called_with(
52
            '<get_tasks trash="1"/>')
53
54
    def test_get_tasks_with_details(self):
55
        self.gmp.get_tasks(details=True)
56
57
        self.connection.send.has_been_called_with(
58
            '<get_tasks details="1"/>')
59
60
    def test_get_tasks_without_details(self):
61
        self.gmp.get_tasks(details=False)
62
63
        self.connection.send.has_been_called_with(
64
            '<get_tasks details="0"/>')
65
66
    def test_get_tasks_with_schedules_only(self):
67
        self.gmp.get_tasks(schedules_only=True)
68
69
        self.connection.send.has_been_called_with(
70
            '<get_tasks schedules_only="1"/>')
71
72
73
if __name__ == '__main__':
74
    unittest.main()
75