File: podman_test.py

package info (click to toggle)
python-mitogen 0.3.26-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,456 kB
  • sloc: python: 22,134; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (44 lines) | stat: -rw-r--r-- 1,275 bytes parent folder | download | duplicates (3)
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
import os

import testlib


class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
    def test_okay(self):
        stub_path = testlib.data_path('stubs/stub-podman.py')

        context = self.router.podman(
            container='container_name',
            podman_path=stub_path,
        )
        stream = self.router.stream_by_id(context.context_id)

        argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
        expected_call = [
            stub_path,
            'exec',
            '--interactive',
            '--',
            'container_name',
            stream.conn.options.python_path
        ]
        self.assertEqual(argv[:len(expected_call)], expected_call)

        context = self.router.podman(
            container='container_name',
            podman_path=stub_path,
            username='some_user',
        )
        stream = self.router.stream_by_id(context.context_id)

        argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
        expected_call = [
            stub_path,
            'exec',
            '--user=some_user',
            '--interactive',
            '--',
            'container_name',
            stream.conn.options.python_path
        ]
        self.assertEqual(argv[:len(expected_call)], expected_call)