2012-08-28 09:03:11 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-08-30 20:14:02 +00:00
|
|
|
'''
|
2018-05-28 21:13:12 +00:00
|
|
|
:codeauthor: Pedro Algarvio (pedro@algarvio.me)
|
2013-09-16 16:24:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
tests.unit.utils.filebuffer_test
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2012-08-30 20:14:02 +00:00
|
|
|
'''
|
2012-08-28 09:03:11 +00:00
|
|
|
|
2014-11-21 19:05:13 +00:00
|
|
|
# Import Python libs
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2013-06-24 22:53:59 +00:00
|
|
|
# Import Salt Testing libs
|
2017-02-27 13:58:07 +00:00
|
|
|
from tests.support.unit import TestCase
|
2013-06-27 13:13:23 +00:00
|
|
|
|
|
|
|
# Import salt libs
|
|
|
|
from salt.utils.filebuffer import BufferedReader, InvalidFileMode
|
2013-06-24 22:53:59 +00:00
|
|
|
|
2012-12-11 10:23:37 +00:00
|
|
|
|
2012-08-28 09:03:11 +00:00
|
|
|
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')
|