Пример #1
0
 def test__update_root_links__formula_dirs_not_exist(self,
                                                     mock_path_exists):
     """
     Test we have an exception when we can't find a any directory
     """
     # Setup
     sample_dependencies = {
         'test_organisation/test1-formula': {
             'source': '[email protected]:test_organisation/test1-formula.git',
             'constraint': '==v1.0.1',
             'organisation': 'test_organisation',
             'name': 'test1-formula'
         },
     }
     testobj = ShakerRemote(sample_dependencies)
     # Set path exists check values
     # True: formula-repos/docker-formula/docker exists
     # False: _root/docker exists
     mock_path_exists.side_effect = [
         False,
         False
     ]
     testobj._update_root_links()
     source = "vendor/formula-repos/test1-formula/test1"
     target = "vendor/_root/test1"
     mock_symlink.assert_called_with(source, target)
     mock_link_dynamic_modules.assert_called_with()
Пример #2
0
 def test__update_root_links__formula_subdir_not_exist(
         self, mock_path_exists, mock_symlink, mock_link_dynamic_modules):
     """
     Test root links are made when our formula has no subdir docker/ structure
     """
     # Setup
     sample_dependencies = {
         'test_organisation/test1': {
             'source': '[email protected]:test_organisation/test1.git',
             'constraint': '==v1.0.1',
             'organisation': 'test_organisation',
             'name': 'test1'
         },
     }
     testobj = ShakerRemote(sample_dependencies)
     # Set path exists check values
     # False: formula-repos/docker-formula/docker exists
     # True: formula-repos/docker/ exists
     # False: _root/docker exists
     mock_path_exists.side_effect = [False, True, False]
     testobj._update_root_links()
     relative_source = "../formula-repos/test1"
     target = "vendor/_root/test1"
     mock_symlink.assert_called_once_with(relative_source, target)
     mock_link_dynamic_modules.assert_called_once_with("test1")
Пример #3
0
 def test__update_root_links__formula_link_exists(self,
                                                  mock_path_exists,
                                                  mock_symlink,
                                                  mock_link_dynamic_modules):
     """
     Test root links are made when our formula has no subdir docker-formula/ structure
     """
     # Setup
     sample_dependencies = {
         'test_organisation/test1-formula': {
             'source': '[email protected]:test_organisation/test1-formula.git',
             'constraint': '==v1.0.1',
             'organisation': 'test_organisation',
             'name': 'test1-formula'
         },
     }
     testobj = ShakerRemote(sample_dependencies)
     # Set path exists check values
     # True: formula-repos/docker-formula/docker exists
     # True: _root/docker exists
     mock_path_exists.side_effect = [
         True,
         True
     ]
     testobj._update_root_links()
Пример #4
0
 def test__update_root_links__formula_subdir_not_exist(self,
                                                       mock_path_exists,
                                                       mock_symlink,
                                                       mock_link_dynamic_modules):
     """
     Test root links are made when our formula has no subdir docker/ structure
     """
     # Setup
     sample_dependencies = {
         'test_organisation/test1': {
             'source': '[email protected]:test_organisation/test1.git',
             'constraint': '==v1.0.1',
             'organisation': 'test_organisation',
             'name': 'test1'
         },
     }
     testobj = ShakerRemote(sample_dependencies)
     # Set path exists check values
     # False: formula-repos/docker-formula/docker exists
     # True: formula-repos/docker/ exists
     # False: _root/docker exists
     mock_path_exists.side_effect = [
         False,
         True,
         False
     ]
     testobj._update_root_links()
     relative_source = "../formula-repos/test1"
     target = "vendor/_root/test1"
     mock_symlink.assert_called_once_with(relative_source, target)
     mock_link_dynamic_modules.assert_called_once_with("test1")
Пример #5
0
    def test_write_requirements__simple(self, mock_path_exists, mock_open,
                                        mock_write):
        """
        TestShakerMetadata: Test resolved dependency are correctly written out to file
        """

        # Setup
        testobj = ShakerRemote(self._sample_dependencies)
        output_directory = "tests/files"
        output_filename = "test_dependencies.txt"
        output_path = '%s/%s' % (output_directory, output_filename)

        # Simple write
        mock_path_exists.return_value = False
        testobj.write_requirements(output_directory,
                                   output_filename,
                                   overwrite=False,
                                   backup=False)
        mock_open.assert_called_once_with(output_path, 'w')
        mock_write.assert_called_once(self._sample_requirements)
Пример #6
0
    def test_write_requirements__overwrite(self, mock_path_exists, mock_open,
                                           mock_write):
        """
        TestShakerMetadata: Test resolved dependency overwrites an existing file when forced
        """

        # Setup
        testobj = ShakerRemote(self._sample_dependencies)
        output_directory = "tests/files"
        output_filename = "test_dependencies.txt"
        output_path = '%s/%s' % (output_directory, output_filename)

        # Overwrite an existing file
        mock_path_exists.return_value = True
        testobj.write_requirements(output_directory,
                                   output_filename,
                                   overwrite=True,
                                   backup=False)
        mock_open.assert_called_once_with(output_path, 'w')
        mock_write.assert_called_once(self._sample_requirements)
Пример #7
0
 def test__update_root_links__formula_link_exists(
         self, mock_path_exists, mock_symlink, mock_link_dynamic_modules):
     """
     Test root links are made when our formula has no subdir docker-formula/ structure
     """
     # Setup
     sample_dependencies = {
         'test_organisation/test1-formula': {
             'source': '[email protected]:test_organisation/test1-formula.git',
             'constraint': '==v1.0.1',
             'organisation': 'test_organisation',
             'name': 'test1-formula'
         },
     }
     testobj = ShakerRemote(sample_dependencies)
     # Set path exists check values
     # True: formula-repos/docker-formula/docker exists
     # True: _root/docker exists
     mock_path_exists.side_effect = [True, True]
     testobj._update_root_links()
Пример #8
0
    def test_write_requirements__no_overwrite(self, mock_path_exists,
                                              mock_open, mock_write):
        """
        TestShakerMetadata: Test resolved dependency do not overwrite an existing file
        """

        # Setup
        testobj = ShakerRemote(self._sample_dependencies)
        output_filename = "test_dependencies.txt"

        # Don't overwrite an existing file
        mock_path_exists.return_value = True
        testobj.write_requirements(output_filename,
                                   overwrite=False,
                                   backup=False)
        self.assertFalse(mock_open.called,
                         ("With overwrite disabled, "
                          "we shouldn't have called to open"))
        self.assertFalse(mock_write.called,
                         ("With overwrite disabled, "
                          "we shouldn't have called to write"))
Пример #9
0
    def test_write_requirements__no_overwrite(self,
                                              mock_path_exists,
                                              mock_open,
                                              mock_write):
        """
        TestShakerMetadata: Test resolved dependency do not overwrite an existing file
        """

        # Setup
        testobj = ShakerRemote(self._sample_dependencies)
        output_filename = "test_dependencies.txt"

        # Don't overwrite an existing file
        mock_path_exists.return_value = True
        testobj.write_requirements(output_filename,
                                   overwrite=False,
                                   backup=False)
        self.assertFalse(mock_open.called, ("With overwrite disabled, "
                                            "we shouldn't have called to open"))
        self.assertFalse(mock_write.called, ("With overwrite disabled, "
                                             "we shouldn't have called to write"))
Пример #10
0
    def test_write_requirements__simple(self,
                                        mock_path_exists,
                                        mock_open,
                                        mock_write):
        """
        TestShakerMetadata: Test resolved dependency are correctly written out to file
        """

        # Setup
        testobj = ShakerRemote(self._sample_dependencies)
        output_directory = "tests/files"
        output_filename = "test_dependencies.txt"
        output_path = '%s/%s' % (output_directory,
                                 output_filename)

        # Simple write
        mock_path_exists.return_value = False
        testobj.write_requirements(output_directory,
                                   output_filename,
                                   overwrite=False,
                                   backup=False)
        mock_open.assert_called_once_with(output_path, 'w')
        mock_write.assert_called_once(self._sample_requirements)
Пример #11
0
    def test_write_requirements__overwrite(self,
                                           mock_path_exists,
                                           mock_open,
                                           mock_write):
        """
        TestShakerMetadata: Test resolved dependency overwrites an existing file when forced
        """

        # Setup
        testobj = ShakerRemote(self._sample_dependencies)
        output_directory = "tests/files"
        output_filename = "test_dependencies.txt"
        output_path = '%s/%s' % (output_directory,
                                 output_filename)

        # Overwrite an existing file
        mock_path_exists.return_value = True
        testobj.write_requirements(output_directory,
                                   output_filename,
                                   overwrite=True,
                                   backup=False)
        mock_open.assert_called_once_with(output_path, 'w')
        mock_write.assert_called_once(self._sample_requirements)
Пример #12
0
 def test__update_root_links__formula_dirs_not_exist(
         self, mock_path_exists):
     """
     Test we have an exception when we can't find a any directory
     """
     # Setup
     sample_dependencies = {
         'test_organisation/test1-formula': {
             'source': '[email protected]:test_organisation/test1-formula.git',
             'constraint': '==v1.0.1',
             'organisation': 'test_organisation',
             'name': 'test1-formula'
         },
     }
     testobj = ShakerRemote(sample_dependencies)
     # Set path exists check values
     # True: formula-repos/docker-formula/docker exists
     # False: _root/docker exists
     mock_path_exists.side_effect = [False, False]
     testobj._update_root_links()
     source = "vendor/formula-repos/test1-formula/test1"
     target = "vendor/_root/test1"
     mock_symlink.assert_called_with(source, target)
     mock_link_dynamic_modules.assert_called_with()