Code Duplication    Length = 40-40 lines in 2 locations

tests/protocols/gmpv208/testcmds/test_get_assets.py 1 location

@@ 26-65 (lines=40) @@
23
from gvm.protocols.gmpv208 import AssetType
24
25
26
class GmpGetAssetsTestCase:
27
    def test_get_assets(self):
28
        self.gmp.get_assets(AssetType.OPERATING_SYSTEM)
29
30
        self.connection.send.has_been_called_with('<get_assets type="os"/>')
31
32
        self.gmp.get_assets(asset_type=AssetType.OPERATING_SYSTEM)
33
34
        self.connection.send.has_been_called_with('<get_assets type="os"/>')
35
36
        self.gmp.get_assets(asset_type=AssetType.HOST)
37
38
        self.connection.send.has_been_called_with('<get_assets type="host"/>')
39
40
    def test_get_assets_invalid_asset_type(self):
41
        with self.assertRaises(InvalidArgumentType):
42
            self.gmp.get_assets(asset_type=None)
43
44
        with self.assertRaises(InvalidArgumentType):
45
            self.gmp.get_assets(asset_type='')
46
47
        with self.assertRaises(InvalidArgumentType):
48
            self.gmp.get_assets(asset_type='foo')
49
50
    def test_get_assets_with_filter(self):
51
        self.gmp.get_assets(
52
            asset_type=AssetType.OPERATING_SYSTEM, filter='foo=bar'
53
        )
54
55
        self.connection.send.has_been_called_with(
56
            '<get_assets type="os" filter="foo=bar"/>'
57
        )
58
59
    def test_get_assets_with_filter_id(self):
60
        self.gmp.get_assets(
61
            asset_type=AssetType.OPERATING_SYSTEM, filter_id='f1'
62
        )
63
64
        self.connection.send.has_been_called_with(
65
            '<get_assets type="os" filt_id="f1"/>'
66
        )
67
68

tests/protocols/gmpv7/testcmds/test_get_assets.py 1 location

@@ 26-65 (lines=40) @@
23
from gvm.protocols.gmpv7 import AssetType
24
25
26
class GmpGetAssetsTestCase:
27
    def test_get_assets(self):
28
        self.gmp.get_assets(AssetType.OPERATING_SYSTEM)
29
30
        self.connection.send.has_been_called_with('<get_assets type="os"/>')
31
32
        self.gmp.get_assets(asset_type=AssetType.OPERATING_SYSTEM)
33
34
        self.connection.send.has_been_called_with('<get_assets type="os"/>')
35
36
        self.gmp.get_assets(asset_type=AssetType.HOST)
37
38
        self.connection.send.has_been_called_with('<get_assets type="host"/>')
39
40
    def test_get_assets_invalid_asset_type(self):
41
        with self.assertRaises(InvalidArgumentType):
42
            self.gmp.get_assets(asset_type=None)
43
44
        with self.assertRaises(InvalidArgumentType):
45
            self.gmp.get_assets(asset_type='')
46
47
        with self.assertRaises(InvalidArgumentType):
48
            self.gmp.get_assets(asset_type='foo')
49
50
    def test_get_assets_with_filter(self):
51
        self.gmp.get_assets(
52
            asset_type=AssetType.OPERATING_SYSTEM, filter='foo=bar'
53
        )
54
55
        self.connection.send.has_been_called_with(
56
            '<get_assets type="os" filter="foo=bar"/>'
57
        )
58
59
    def test_get_assets_with_filter_id(self):
60
        self.gmp.get_assets(
61
            asset_type=AssetType.OPERATING_SYSTEM, filter_id='f1'
62
        )
63
64
        self.connection.send.has_been_called_with(
65
            '<get_assets type="os" filt_id="f1"/>'
66
        )
67
68