예제 #1
0
파일: test_edits.py 프로젝트: cgwire/zou
    def test_remove_edit_force(self):
        edit = self.generate_fixture_edit()
        self.assertEqual(len(edits_service.get_edits()), 2)
        path = "data/edits/%s?force=true" % edit.id

        self.delete(path)

        self.assertEqual(len(edits_service.get_edits()), 1)
        self.get(path, 404)
예제 #2
0
파일: test_edits.py 프로젝트: cgwire/zou
    def test_remove_edit_with_tasks_force(self):
        edits = edits_service.get_edits()
        self.assertEqual(len(edits), 1)
        path = "data/edits/%s?force=true" % self.edit_dict["id"]

        self.delete(path)

        edits = edits_service.get_edits()
        self.assertEqual(len(edits), 0)
        self.get(path, 404)
예제 #3
0
파일: test_edits.py 프로젝트: cgwire/zou
    def test_remove_edit_with_tasks(self):
        edits = edits_service.get_edits()
        self.assertEqual(len(edits), 1)
        path = "data/edits/%s" % self.edit_dict["id"]

        self.delete(path)

        edits = edits_service.get_edits()
        self.assertEqual(len(edits), 1)
        self.assertEqual(edits[0]["canceled"], True)
        self.get(path, 200)
예제 #4
0
파일: test_edits.py 프로젝트: cgwire/zou
    def test_remove_edit(self):
        edit = self.generate_fixture_edit()
        edits = edits_service.get_edits()
        self.assertEqual(len(edits), 2)
        path = "data/edits/%s" % edit.id

        self.delete(path)

        edits = edits_service.get_edits()
        self.assertEqual(len(edits), 1)
        self.get(path, 404)
예제 #5
0
파일: test_edits.py 프로젝트: cgwire/zou
    def test_create_edit(self):
        events.register("edit:new", "handle_event", self)
        new_edit_data = {
            "name": "Director's Cut",
            "description": "Test Edit description",
            "data": {
                "extra": "test extra"
            },
        }
        path = "data/projects/%s/edits" % (self.project.id, )

        edit = self.post(path, new_edit_data)

        edits = edits_service.get_edits()
        self.assertIsNotNone(edit.get("id", None))
        self.assertEqual(len(edits), 2)
        self.assertEqual(
            {edit["name"]
             for edit in edits},
            {self.edit_dict["name"], new_edit_data["name"]},
        )
        self.assertEqual(edit["name"], new_edit_data["name"])
        self.assertIsNone(edit["parent_id"])
        self.assertEqual(edit["type"], "Edit")
        self.assertEqual(edit["description"], new_edit_data["description"])
        self.assertDictEqual(edit["data"], new_edit_data["data"])
예제 #6
0
파일: resources.py 프로젝트: cgwire/zou
 def get(self):
     """
     Retrieve all edit entries. Filters can be specified in the query string.
     """
     criterions = query.get_query_criterions_from_request(request)
     if permissions.has_vendor_permissions():
         criterions["assigned_to"] = persons_service.get_current_user(
         )["id"]
     user_service.check_project_access(criterions.get("project_id", None))
     return edits_service.get_edits(criterions)
예제 #7
0
    def post(self, project_id, task_type_id):
        """
        Create a new task for given edit and task type.
        ---
        tags:
        - Tasks
        parameters:
          - in: path
            name: project_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
          - in: path
            name: task_type_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
        responses:
            201:
                description: New task for given edit and task type created
        """
        user_service.check_manager_project_access(project_id)
        task_type = tasks_service.get_task_type(task_type_id)

        edit_ids = request.json
        edits = []
        if type(edit_ids) == list and len(edit_ids) > 0:
            for edit_id in edit_ids:
                edit = edits_service.get_edit(edit_id)
                if edit["project_id"] == project_id:
                    edits.append(edit)
        else:
            criterions = query.get_query_criterions_from_request(request)
            criterions["project_id"] = project_id
            edits = edits_service.get_edits(criterions)

        tasks = tasks_service.create_tasks(task_type, edits)
        return tasks, 201
예제 #8
0
 def test_get_edits(self):
     edits = edits_service.get_edits()
     self.edit_dict = self.edit.serialize(obj_type="Edit")
     self.edit_dict["project_name"] = self.project.name
     self.assertDictEqual(edits[0], self.edit_dict)