File: policy_function_test.py

package info (click to toggle)
python-mitogen 0.3.25~a2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 6,220 kB
  • sloc: python: 21,989; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (37 lines) | stat: -rw-r--r-- 964 bytes parent folder | download
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
try:
    from unittest import mock
except ImportError:
    import mock

import mitogen.core
import mitogen.parent

import testlib


class HasParentAuthorityTest(testlib.TestCase):
    func = staticmethod(mitogen.core.has_parent_authority)

    def call(self, auth_id):
        msg = mitogen.core.Message(auth_id=auth_id)
        return self.func(msg)

    @mock.patch('mitogen.context_id', 5555)
    @mock.patch('mitogen.parent_ids', [111, 222])
    def test_okay(self):
        self.assertFalse(self.call(0))
        self.assertTrue(self.call(5555))
        self.assertTrue(self.call(111))


class IsImmediateChildTest(testlib.TestCase):
    func = staticmethod(mitogen.core.has_parent_authority)

    def call(self, auth_id, remote_id):
        msg = mitogen.core.Message(auth_id=auth_id)
        stream = mock.Mock(remote_id=remote_id)
        return self.func(msg, stream)

    def test_okay(self):
        self.assertFalse(0, 1)
        self.assertTrue(1, 1)