예제 #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()
예제 #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)
예제 #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)
예제 #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"))
예제 #5
0
파일: resource.py 프로젝트: RaigaX9/ranger
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)
예제 #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")