Пример #1
0
    def test_checks_etc_passwd(self):
        with mock.patch("builtins.open", mock.mock_open()) as mock_open:
            lines = ["root:x:0:0:root:/root:/bin/bash", "somename:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin"]

            mock_open.return_value.__iter__.return_value = lines

            with mock.patch("ocflib.misc.mail.send_problem_report") as send_report:
                assert username_reserved("somename")
                assert send_report.called
Пример #2
0
    def test_checks_etc_passwd(self):
        lines = [
            'root:x:0:0:root:/root:/bin/bash',
            'somename:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin'
        ]

        with mock.patch('builtins.open',
                        new=mock.mock_open(read_data='\n'.join(lines))):
            with mock.patch('ocflib.misc.mail.send_problem_report') \
                    as send_report:
                assert username_reserved('somename')
                assert send_report.called
Пример #3
0
    def test_checks_etc_passwd(self):
        with mock.patch('builtins.open', mock.mock_open()) as mock_open:
            lines = [
                'root:x:0:0:root:/root:/bin/bash',
                'somename:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin',
            ]

            mock_open.return_value.__iter__.return_value = lines

            with mock.patch('ocflib.misc.mail.send_problem_report') \
                    as send_report:
                assert username_reserved('somename')
                assert send_report.called
Пример #4
0
 def test_not_reserved(self, username):
     assert not username_reserved(username)
Пример #5
0
 def test_not_reserved(self, username):
     assert not username_reserved(username)