class FileWrapperTest(unittest.TestCase): def setUp(self): self.sut = FileWrapper() def test_json_load(self): # Fixture path = "some/path" data = {'some': 'data'} data_json = json.dumps(data) with patch('builtins.open', mock_open(read_data=data_json), create=True) as mock: # Test actual = self.sut.json_load(path) # Assert self.assertEqual(data, actual) mock.assert_called_once_with(path, 'r') def test_json_dump(self): # Fixture path = "some/path" data = {'some': 'data'} data_json = json.dumps(data) with patch('builtins.open', mock_open(read_data=data_json), create=True) as mock: # Test self.sut.json_dump(data, path) # Assert mock.assert_called_once_with(path, 'w') def test_read(self): # Fixture path = "some/path" data = 'Some data' with patch('builtins.open', mock_open(read_data=data), create=True) as mock: # Test actual = self.sut.read(path) # Assert self.assertEqual(data, actual) mock.assert_called_once_with(path, 'r')
def __init__(self, docker=Docker(), runner=Runner(), file_wrapper=FileWrapper()): self.docker = docker self.runner = runner self.file_wrapper = file_wrapper
def __init__(self): self.sub_proc = SubProc() self.docker = Docker(self.sub_proc) self.runner = Runner(self.docker) self.file_wrapper = FileWrapper() self.bc_module = BcModule(self.docker, self.runner, self.file_wrapper) self.git = Git(self.sub_proc) self.ui = Ui() self.tools = [ help.Help(self.bc_module), update.Update(self.docker), version.Version(self.docker), ghrn.Ghrn(self.docker), docs.Docs(self.docker), ] self.config_reader = ConfigReader(self.file_wrapper, self.bc_module, self.tools)
def setUp(self): self.sut = FileWrapper()
def __init__(self, file_wrapper=FileWrapper(), bc_module=BcModule()): self.file_wrapper = file_wrapper self.bc_module = bc_module