示例#1
0
文件: tests.py 项目: quuhua911/cvat
    def test_init_repos(self):
        for git_rep_already_init in [True, False]:
            task = self._create_task(init_repos=git_rep_already_init)
            db_task = Task.objects.get(pk=task["id"])
            db_git = GitData()
            db_git.url = GIT_URL

            cvat_git = TestGit(db_git, db_task, self.user)
            cvat_git.init_repos()
            self.assertTrue(osp.isdir(osp.join(cvat_git.get_working_dir(), '.git')))
示例#2
0
文件: tests.py 项目: quuhua911/cvat
    def test_clone(self):
        task = self._create_task(init_repos=False)
        db_task = Task.objects.get(pk=task["id"])
        db_git = GitData()
        db_git.url = GIT_URL

        cvat_git = TestGit(db_git, db_task, self.user)
        cvat_git.clone()
        repo = cvat_git.get_rep()
        self.assertTrue(osp.isdir(osp.join(cvat_git.get_working_dir(), '.git')))
        self.assertTrue(len(repo.heads))
示例#3
0
    def test_push(self):
        task = self._create_task(init_repos=True)
        db_task = Task.objects.get(pk=task["id"])
        db_git = GitData()
        db_git.url = GIT_URL
        db_git.path = "annotation.zip"
        db_git.sync_date = timezone.now()

        cvat_git = TestGit(db_git, db_task, self.user)
        cvat_git.set_rep()
        cvat_git.create_master_branch()
        self.add_file(cvat_git.get_cwd(), "file.txt")
        cvat_git.push(self.user, "", "", db_task, db_task.updated_date)
        self.assertFalse(cvat_git.get_rep().is_dirty())
示例#4
0
def initial_create(tid, git_path, lfs, user):
    try:
        db_task = Task.objects.get(pk = tid)
        path_pattern = r"\[(.+)\]"
        path_search = re.search(path_pattern, git_path)
        path = None

        if path_search is not None:
            path = path_search.group(1)
            git_path = git_path[0:git_path.find(path) - 1].strip()
            path = os.path.join('/', path.strip())
        else:
            anno_file = re.sub(r'[\\/*?:"<>|\s]', '_', db_task.name)[:100]
            path = '/annotation/{}.zip'.format(anno_file)

        path = path[1:]
        _split = os.path.splitext(path)
        if len(_split) < 2 or _split[1] not in [".xml", ".zip"]:
            raise Exception("Only .xml and .zip formats are supported")

        db_git = GitData()
        db_git.url = git_path
        db_git.path = path
        db_git.task = db_task
        db_git.lfs = lfs

        try:
            _git = Git(db_git, db_task, db_task.owner)
            _git.init_repos()
            db_git.save()
        except git.exc.GitCommandError as ex:
            _have_no_access_exception(ex)
    except Exception as ex:
        slogger.task[tid].exception('exception occurred during git initial_create', exc_info = True)
        raise ex
示例#5
0
    def test_request_on_save(self):
        task = self._create_task(init_repos=False)
        tid = task["id"]
        initial_create(tid, GIT_URL, 1, self.user)

        jobs = self._get_jobs(tid)
        ann = {
            "version":
            0,
            "tags": [],
            "shapes": [
                {
                    "type": "points",
                    "occluded": False,
                    "z_order": 1,
                    "points": [42.95, 33.59],
                    "frame": 1,
                    "label_id": 1,
                    "group": 0,
                    "source": "manual",
                    "attributes": []
                },
            ],
            "tracks": []
        }
        self._run_api_v1_job_id_annotation(jobs[0]["id"], ann, self.user)
        db_git = GitData()
        self.assertEqual(db_git.status, GitStatusChoice.NON_SYNCED)
示例#6
0
    def test_git_create_master_branch(self):
        task = self._create_task(init_repos=True)
        db_task = Task.objects.get(pk=task["id"])
        db_git = GitData()
        db_git.url = GIT_URL

        cvat_git = TestGit(db_git, db_task, self.user)
        cvat_git.set_rep()
        cvat_git.create_master_branch()
        cwd = cvat_git.get_cwd()
        self.assertTrue(osp.isfile(osp.join(cwd, "README.md")))

        repo = cvat_git.get_rep()
        self.assertFalse(repo.is_dirty())
        self.assertTrue(len(repo.heads) == 1)
        self.assertTrue(repo.heads[0].name == "master")
示例#7
0
文件: tests.py 项目: quuhua911/cvat
    def test_configurate(self):
        task = self._create_task(init_repos=True)
        db_task = Task.objects.get(pk=task["id"])
        db_git = GitData()

        cvat_git = TestGit(db_git, db_task, self.user)
        cvat_git.set_rep()
        cvat_git.configurate()

        repo = cvat_git.get_rep()
        self.assertTrue(len(repo.heads))
        self.assertTrue(osp.isdir(osp.join(db_task.get_task_artifacts_dirname(), "repos_diffs_v2")))
示例#8
0
    def test_update_config(self):
        for user in [self.admin, self.user]:
            task = self._create_task(init_repos=True)
            db_task = Task.objects.get(pk=task["id"])
            db_git = GitData()

            cvat_git = TestGit(db_git, db_task, user)
            cvat_git.set_rep()
            cvat_git.create_master_branch()

            cvat_git.update_config()
            repo = cvat_git.get_rep()
            with repo.config_reader() as cw:
                self.assertEqual(user.username, cw.get("user", "name"))
                self.assertEqual(user.email, cw.get("user", "email"))
示例#9
0
    def test_to_task_branch(self):
        task = self._create_task(init_repos=True)
        tid = task["id"]
        task_name = task["name"]
        db_task = Task.objects.get(pk=tid)
        db_git = GitData()

        cvat_git = TestGit(db_git, db_task, self.user)
        cvat_git.set_rep()
        cvat_git.create_master_branch()
        cvat_git.to_task_branch()

        repo = cvat_git.get_rep()
        heads = [head.name for head in repo.heads]
        self.assertTrue('cvat_{}_{}'.format(tid, task_name) in heads)
示例#10
0
 def setUp(self):
     self.client = APIClient()
     db_git = GitData()
     db_git.url = GIT_URL