1 | #!/usr/bin/python
|
---|
2 | #
|
---|
3 | # Python integration for tevent - tests
|
---|
4 | #
|
---|
5 | # Copyright (C) Jelmer Vernooij 2010
|
---|
6 | #
|
---|
7 | # ** NOTE! The following LGPL license applies to the tevent
|
---|
8 | # ** library. This does NOT imply that all of Samba is released
|
---|
9 | # ** under the LGPL
|
---|
10 | #
|
---|
11 | # This library is free software; you can redistribute it and/or
|
---|
12 | # modify it under the terms of the GNU Lesser General Public
|
---|
13 | # License as published by the Free Software Foundation; either
|
---|
14 | # version 3 of the License, or (at your option) any later version.
|
---|
15 | #
|
---|
16 | # This library is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | # Lesser General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU Lesser General Public
|
---|
22 | # License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
---|
23 |
|
---|
24 | import signal
|
---|
25 | import _tevent
|
---|
26 | from unittest import TestCase
|
---|
27 |
|
---|
28 | class BackendListTests(TestCase):
|
---|
29 |
|
---|
30 | def test_backend_list(self):
|
---|
31 | self.assertTrue(isinstance(_tevent.backend_list(), list))
|
---|
32 |
|
---|
33 |
|
---|
34 | class CreateContextTests(TestCase):
|
---|
35 |
|
---|
36 | def test_by_name(self):
|
---|
37 | ctx = _tevent.Context(_tevent.backend_list()[0])
|
---|
38 | self.assertTrue(ctx is not None)
|
---|
39 |
|
---|
40 | def test_no_name(self):
|
---|
41 | ctx = _tevent.Context()
|
---|
42 | self.assertTrue(ctx is not None)
|
---|
43 |
|
---|
44 |
|
---|
45 | class ContextTests(TestCase):
|
---|
46 |
|
---|
47 | def setUp(self):
|
---|
48 | super(ContextTests, self).setUp()
|
---|
49 | self.ctx = _tevent.Context()
|
---|
50 |
|
---|
51 | def test_signal_support(self):
|
---|
52 | self.assertTrue(type(self.ctx.signal_support) is bool)
|
---|
53 |
|
---|
54 | def test_reinitialise(self):
|
---|
55 | self.ctx.reinitialise()
|
---|
56 |
|
---|
57 | def test_loop_wait(self):
|
---|
58 | self.ctx.loop_wait()
|
---|
59 |
|
---|
60 | def test_add_signal(self):
|
---|
61 | sig = self.ctx.add_signal(signal.SIGINT, 0, lambda callback: None)
|
---|
62 | self.assertTrue(isinstance(sig, _tevent.Signal))
|
---|