Passed
Push — master ( e601a7...eb7115 )
by Humberto
02:04 queued 14s
created

TestNAppDirListener.setUp()   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
"""Test kytos.core.napps.napps_dir_listener module."""
2
from unittest import TestCase
3
from unittest.mock import Mock
4
5
from kytos.core.napps.napp_dir_listener import NAppDirListener
6
7
8
class TestNAppDirListener(TestCase):
9
    """NAppDirListener tests."""
10
11
    def setUp(self):
12
        """Method executed before each test."""
13
        self.controller = Mock()
14
        self.controller.options.napps = '/tmp'
15
        self.napp_dir_listener = NAppDirListener(self.controller)
16
        self.event = Mock(src_path='/tmp/username/napp_name/')
17
18
    def test_on_created(self):
19
        """Test whether on_created is calling load_napp."""
20
        self.napp_dir_listener.on_created(self.event)
21
        self.controller.load_napp.assert_called_with("username", "napp_name")
22
23
    def test_on_deleted(self):
24
        """Test whether on_deleted is calling unload_napp."""
25
        self.napp_dir_listener.on_deleted(self.event)
26
        self.controller.unload_napp.assert_called_with("username", "napp_name")
27