Esempio n. 1
0
 def test_get_sot_no_sot_type(self):
     """Check that a runtime error is raised if no git type
     is available from config
     """
     sot_factory.sot_type = ""
     with self.assertRaises(RuntimeError):
         sot_factory.get_sot()
Esempio n. 2
0
 def test_get_sot_git_type(self):
     """ Check that when 'git' type is provided the returned object
     is instance of  GiTSoT
     """
     sot_factory.sot_type = "git"
     obj = sot_factory.get_sot()
     self.assertIsInstance(obj, GitSoT)
Esempio n. 3
0
    def test_git_sot_get_resource_file_path_failed(self):
        """get_resource_file_path """
        sot_factory.sot_type = "git"
        sot_factory.git_type = "native"
        sot_factory.local_repository_path = conf.git["local_repository_path"]
        sot_factory.relative_path_format = conf.git["relative_path_format"]
        sot_factory.file_name_format = conf.git["file_name_format"]
        sot_factory.get_sot()

        name = conf.git["file_name_format"].format(resource["resource_name"])
        path = conf.git["local_repository_path"] + \
            conf.git["relative_path_format"].format(resource["region_id"],
                                                    resource["resource_type"],
                                                    name)

        result_path = sot.get_resource_file_path(resource)
        self.assertEqual(path, result_path)
Esempio n. 4
0
 def test_git_sot_save_resource_to_sot(self, thread):
     """Check the save runs in a new thread"""
     sot_factory.sot_type = "git"
     sot_factory.git_type = "gittle"
     git_impl = mock.MagicMock()
     sot = sot_factory.get_sot()
     sot.save_resource_to_sot("t_id", "tk_id", [], "a_id", "u_id")
     self.assertNotEqual(thread, threading.Thread.getName("main_thread"))
Esempio n. 5
0
def _upload_to_sot(uuid, tranid, targetslist):
    application_id = request.headers[
        'X-RANGER-Client'] if 'X-RANGER-Client' in request.headers else \
        'NA'
    user_id = request.headers[
        'X-RANGER-Requester'] if 'X-RANGER-Requester' in request.headers else \
        ''
    sot = sot_factory.get_sot()
    sot.save_resource_to_sot(uuid,
                             tranid,
                             targetslist,
                             application_id,
                             user_id)
Esempio n. 6
0
    def test_get_sot_git_sot_params(self):
        sot_factory.sot_type = "git"
        sot_factory.local_repository_path = "2"
        sot_factory.relative_path_format = "3"
        sot_factory.commit_message_format = "4"
        sot_factory.commit_user = "******"
        sot_factory.commit_email = "6"
        sot_factory.git_server_url = "7"
        sot_factory.git_type = "gittle"

        obj = sot_factory.get_sot()
        self.assertEqual(GitSoT.local_repository_path, "2",
                         "local_repository_path not match")
        self.assertEqual(GitSoT.relative_path_format, "3",
                         "relative_path_format not match")
        self.assertEqual(GitSoT.commit_message_format, "4",
                         "commit_message_format not match")
        self.assertEqual(GitSoT.commit_user, "5", "commit_user not match")
        self.assertEqual(GitSoT.commit_email, "6", "commit_email not match")
        self.assertEqual(GitSoT.git_server_url, "7",
                         "git_server_url not match")
        self.assertEqual(GitSoT.git_type, "gittle", "git_type not match")