Пример #1
0
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')
Пример #2
0
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')
Пример #3
0
 def __init__(self,
              docker=Docker(),
              runner=Runner(),
              file_wrapper=FileWrapper()):
     self.docker = docker
     self.runner = runner
     self.file_wrapper = file_wrapper
Пример #4
0
    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)
Пример #5
0
 def setUp(self):
     self.sut = FileWrapper()
Пример #6
0
 def setUp(self):
     self.sut = FileWrapper()
Пример #7
0
 def __init__(self, file_wrapper=FileWrapper(), bc_module=BcModule()):
     self.file_wrapper = file_wrapper
     self.bc_module = bc_module