Source code for amazon_dash.tests.base
import os
from ._compat import patch
from pyfakefs.fake_filesystem_unittest import Patcher
[docs]class FileMockBase(object):
contents = ''
[docs] def setUp(self):
self.patcher = Patcher()
self.patcher.setUp()
self.file = 'config.yml'
self.patcher.fs.CreateFile(self.file, contents=self.contents)
[docs] def tearDown(self):
self.patcher.tearDown()
[docs]class ConfigFileMockBase(FileMockBase):
[docs] def setUp(self):
self.getuid_mock = patch('os.getuid', return_value=1000)
self.getuid_mock.start()
super(ConfigFileMockBase, self).setUp()
os.chown(self.file, 1000, 1000)
os.chmod(self.file, 0o660)
[docs] def tearDown(self):
self.getuid_mock.stop()
super(ConfigFileMockBase, self).tearDown()
[docs]class ExecuteMockBase(object):
[docs] def setUp(self):
self.execute_mock = patch('amazon_dash.execute.execute_cmd', return_value=None)
self.execute_mock_req = self.execute_mock.start()
super(ExecuteMockBase, self).setUp()
[docs] def tearDown(self):
self.execute_mock.stop()
super(ExecuteMockBase, self).tearDown()