forked from nokia/moler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_device.py
More file actions
52 lines (36 loc) · 1.47 KB
/
Copy pathtest_device.py
File metadata and controls
52 lines (36 loc) · 1.47 KB
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
# -*- coding: utf-8 -*-
__author__ = 'Grzegorz Latuszek, Michal Ernst'
__copyright__ = 'Copyright (C) 2018, Nokia'
__email__ = 'grzegorz.latuszek@nokia.com, michal.ernst@nokia.com'
import pytest
def test_device_directly_created_must_be_given_io_connection(buffer_connection):
from moler.device.unixlocal import UnixLocal
dev = UnixLocal(io_connection=buffer_connection)
assert dev.io_connection == buffer_connection
def test_device_may_be_created_on_named_connection(configure_net_1_connection):
from moler.device.unixlocal import UnixLocal
dev = UnixLocal.from_named_connection(connection_name='net_1')
assert dev.io_connection is not None
assert dev.io_connection.name == 'net_1'
def test_device_unix_can_return_cd_command(configure_net_1_connection):
from moler.device.unixlocal import UnixLocal
from moler.cmd.unix.cd import Cd
ux = UnixLocal.from_named_connection(connection_name='net_1')
assert hasattr(ux, 'get_cmd')
assert isinstance(
ux.get_cmd(
cmd_name='cd',
cmd_params={
"path": "/home/user/"
}
),
Cd
)
# --------------------------- resources ---------------------------
@pytest.yield_fixture
def configure_net_1_connection():
from moler.config import connections as conn_cfg
conn_cfg.set_default_variant(io_type='memory', variant="threaded")
conn_cfg.define_connection(name='net_1', io_type='memory')
yield
conn_cfg.clear()