예제 #1
0
    def test_given_a_path_is_empty_then_exception_raised_with_correct_message(self, mock_check_output):

        comp_message = "Two paths must be given to compare folders.\npath 1: , path 2: path_two."

        with self.assertRaises(st.SystemTestingError) as e:
            st.check_if_repos_equal("", "path_two")

        self.assertEqual(str(e.exception), comp_message)
예제 #2
0
    def test_given_a_path_is_empty_then_exception_raised_with_correct_message(self, mock_check_output):

        comp_message = "Two paths must be given to compare folders.\npath 1: , path 2: path_two."

        with self.assertRaises(st.SystemTestingError) as e:
            st.check_if_repos_equal("", "path_two")

        self.assertEqual(str(e.exception), comp_message)
예제 #3
0
    def test_subprocess_check_output_given_correct_input(self, mock_check_output):

        st.check_if_repos_equal("local_path_one", "local_path_two")

        mock_check_output.assert_called_once_with(
            [
                "diff",
                "-rq",
                "--exclude=.git",
                "--exclude=.gitattributes",
                "--exclude=.keep",
                "local_path_one",
                "local_path_two",
            ]
        )
예제 #4
0
    def test_checkout_entire_area(self):

        tempdir = tempfile.mkdtemp()
        cwd = os.getcwd()
        os.chdir(tempdir)

        modules = [
            "controlstest/targetOS/mock_repo/ioc/BTEST/BTEST-EB-IOC-03",
            "controlstest/targetOS/mock_repo/ioc/BTEST/TS",
            "controlstest/targetOS/mock_repo/ioc/BTEST2/TS"
        ]

        should_not_clone = [
            "controlstest/targetOS/mock_repo/python/dls_testpythonmod",
            "controlstest/targetOS/mock_repo/support/testsupportmod"
        ]

        process = subprocess.Popen("dls-checkout-module.py -i".split(),
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   stdin=subprocess.PIPE)

        std_out, std_err = process.communicate('Y'.encode())
        std_out = std_out.decode('utf-8')
        std_err = std_err.decode('utf-8')

        logging.debug("Standard out:\n" + std_out)
        logging.debug("Standard error:\n" + std_err)

        # Check correct folders have been created
        for path in modules:
            assert_true(os.path.isdir(path.split('/', 2)[-1]))
        for path in should_not_clone:
            assert_false(os.path.isdir(path.split('/', 2)[-1]))

        # Check modules have been cloned correctly
        for path in modules:
            repo = path.split('/', 2)[-1]
            clone = Server().temp_clone(path).repo
            comp_repo = clone.working_tree_dir

            assert_true(st.check_if_repos_equal(repo, comp_repo))

        os.chdir(cwd)
        shutil.rmtree(tempdir)
    def test_checkout_entire_area(self):

        tempdir = tempfile.mkdtemp()
        cwd = os.getcwd()
        os.chdir(tempdir)

        modules = ["controlstest/targetOS/mock_repo/ioc/BTEST/BTEST-EB-IOC-03",
                   "controlstest/targetOS/mock_repo/ioc/BTEST/TS",
                   "controlstest/targetOS/mock_repo/ioc/BTEST2/TS"]
        
        should_not_clone = ["controlstest/targetOS/mock_repo/python/dls_testpythonmod",
                            "controlstest/targetOS/mock_repo/support/testsupportmod"]

        process = subprocess.Popen("dls-checkout-module.py -i".split(),
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   stdin=subprocess.PIPE)

        std_out, std_err = process.communicate('Y')

        logging.debug("Standard out:\n" + std_out)
        logging.debug("Standard error:\n" + std_err)

        # Check correct folders have been created
        for path in modules:
            assert_true(os.path.isdir(path.split('/', 2)[-1]))
        for path in should_not_clone:
            assert_false(os.path.isdir(path.split('/', 2)[-1]))

        # Check modules have been cloned correctly
        for path in modules:
            repo = path.split('/', 2)[-1]
            clone = vcs_git.temp_clone(path)
            comp_repo = clone.working_tree_dir

            assert_true(st.check_if_repos_equal(repo, comp_repo))

        os.chdir(cwd)
        shutil.rmtree(tempdir)
예제 #6
0
    def test_given_subprocess_return_code_0_then_function_returns_true(self, mock_check_output):
        mock_check_output.return_value = ""

        return_value = st.check_if_repos_equal("path1", "path2")

        self.assertTrue(return_value)
예제 #7
0
    def test_given_subprocess_return_code_1_then_function_returns_false(self, mock_check_output):
        mock_check_output.side_effect = subprocess.CalledProcessError(1, "This just makes the return code 1")

        return_value = st.check_if_repos_equal("path1", "path2")

        self.assertFalse(return_value)
예제 #8
0
    def test_subprocess_check_output_given_correct_input(self, mock_check_output):

        st.check_if_repos_equal("local_path_one", "local_path_two")

        mock_check_output.assert_called_once_with(['diff', '-rq', '--exclude=.git', '--exclude=.gitattributes', '--exclude=.keep', 'local_path_one', 'local_path_two'])
예제 #9
0
    def test_given_subprocess_return_code_0_then_function_returns_true(self, mock_check_output):
        mock_check_output.return_value = ""

        return_value = st.check_if_repos_equal("path1", "path2")

        self.assertTrue(return_value)
예제 #10
0
    def test_given_subprocess_return_code_1_then_function_returns_false(self, mock_check_output):
        mock_check_output.side_effect = subprocess.CalledProcessError(1, "This just makes the return code 1")

        return_value = st.check_if_repos_equal("path1", "path2")

        self.assertFalse(return_value)