mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
'''
|
|
tests.unit.utils.filebuffer_test
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
:codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)`
|
|
:copyright: © 2012 by the SaltStack Team, see AUTHORS for more details.
|
|
:license: Apache 2.0, see LICENSE for more details.
|
|
'''
|
|
|
|
# Import salt libs
|
|
from saltunittest import TestCase, TestLoader, TextTestRunner
|
|
from salt.utils.filebuffer import BufferedReader, InvalidFileMode
|
|
|
|
|
|
class TestFileBuffer(TestCase):
|
|
def test_read_only_mode(self):
|
|
with self.assertRaises(InvalidFileMode):
|
|
BufferedReader('/tmp/foo', mode='a')
|
|
|
|
with self.assertRaises(InvalidFileMode):
|
|
BufferedReader('/tmp/foo', mode='ab')
|
|
|
|
with self.assertRaises(InvalidFileMode):
|
|
BufferedReader('/tmp/foo', mode='w')
|
|
|
|
with self.assertRaises(InvalidFileMode):
|
|
BufferedReader('/tmp/foo', mode='wb')
|
|
|
|
|
|
if __name__ == "__main__":
|
|
loader = TestLoader()
|
|
tests = loader.loadTestsFromTestCase(TestFileBuffer)
|
|
TextTestRunner(verbosity=1).run(tests)
|