forked from Luos-io/Pyluos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_rename.py
56 lines (39 loc) · 1.69 KB
/
test_rename.py
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
53
54
55
56
import unittest
import random
import string
from contextlib import closing
from pyluos import Device
import fakerobot
# class TestWsRobot(fakerobot.TestCase):
# def test_rename(self):
# with closing(Device(fakerobot.host)) as robot:
# for _ in range(5):
# length = random.randint(1, robot._max_alias_length)
# mod = random.choice(robot.containers)
# old = mod.alias
# new = self.random_name(length)
# robot.rename_container(old, new)
# self.assertTrue(hasattr(robot, new))
# self.assertFalse(hasattr(robot, old))
# def test_unexisting_container(self):
# with closing(Device(fakerobot.host)) as robot:
# while True:
# length = random.randint(1, robot._max_alias_length)
# name = self.random_name(length)
# if not hasattr(robot, name):
# break
# with self.assertRaises(ValueError):
# robot.rename_container(name, 'oups')
# def test_loooooong_name(self):
# with closing(Device(fakerobot.host)) as robot:
# mod = random.choice(robot.containers)
# length = random.randint(robot._max_alias_length + 1,
# robot._max_alias_length + 100)
# long_name = self.random_name(length)
# with self.assertRaises(ValueError):
# robot.rename_container(mod.alias, long_name)
# def random_name(self, length):
# return ''.join(random.choice(string.ascii_lowercase)
# for _ in range(length))
if __name__ == '__main__':
unittest.main()