示例#1
0
 def test_delete_entry(self):
     asset_id = str(self.asset.id)
     events.register("asset:delete", "handle_event", self)
     delete_func = sync_service.delete_entry("assets", "asset", Entity)
     delete_func({"asset_id": asset_id})
     self.assertIsNone(Entity.get(asset_id))
     self.assertTrue("asset_id" in self.last_event_data)
示例#2
0
    def test_publish_task(self):
        handler = ToReviewHandler(self.open_status_id, self.to_review_status_id)
        events.register(
            "task:to-review",
            "mark_event_as_fired",
            handler
        )
        tasks_service.task_to_review(
            self.task.id,
            self.person.serialize(),
            "my comment"
        )
        self.is_event_fired = handler.is_event_fired
        data = handler.data

        task = Task.get(self.task.id)
        self.assertEqual(task.task_status_id, self.to_review_status_id)
        self.assert_event_is_fired()

        self.assertEqual(
            data["previous_task_status_id"],
            str(self.open_status_id)
        )

        self.assertEqual(data["comment"], "my comment")
示例#3
0
 def test_create_asset(self):
     events.register(
         "asset:new",
         "handle_event",
         self
     )
     self.asset_data = {
         "name": "car",
         "description": "Test description",
         "data": {"extra": "test extra"}
     }
     path = "data/projects/%s/asset-types/%s/assets/new" % (
         self.project.id,
         self.entity_type.id
     )
     asset = self.post(path, self.asset_data)
     assets = assets_service.get_assets()
     self.assertIsNotNone(asset.get("id", None))
     self.assertEquals(len(assets), 1)
     self.assertEquals(
         assets[0]["name"],
         self.asset_data["name"]
     )
     self.assertEquals(
         assets[0]["description"],
         self.asset_data["description"]
     )
     self.assertDictEqual(
         assets[0]["data"],
         self.asset_data["data"]
     )
示例#4
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"])
示例#5
0
    def test_publish_task(self):
        handler = ToReviewHandler(self.open_status_id,
                                  self.to_review_status_id)
        events.register("task:to-review", "mark_event_as_fired", handler)
        task_info.to_review_task(self.task, self.output_file.serialize())
        self.is_event_fired = handler.is_event_fired
        data = handler.data

        task = Task.get(self.task.id)
        self.assertEqual(task.task_status_id, self.to_review_status_id)
        self.assert_event_is_fired()

        self.assertEquals(data["task_before"]["task_status_id"],
                          str(self.open_status_id))

        self.assertEquals(data["task_after"]["task_status_id"],
                          str(self.to_review_status_id))

        self.assertEquals(data["task_after"]["project"]["id"],
                          str(self.project.id))

        self.assertEquals(data["task_after"]["entity"]["id"],
                          str(self.entity.id))

        self.assertEquals(data["task_after"]["entity_type"]["id"],
                          str(self.entity_type.id))

        self.assertEquals(data["task_after"]["person"]["id"],
                          str(self.person.id))

        self.assertTrue(data["task_after"]["output_file"]["id"],
                        str(self.output_file.id))
示例#6
0
 def test_register(self):
     events.register("task:start", "inc_counter", self)
     events.emit("task:start")
     self.assertEqual(self.counter, 2)
     events.emit("task:stop")
     self.assertEqual(self.counter, 2)
     events.emit("task:start")
     self.assertEqual(self.counter, 3)
示例#7
0
    def test_status_to_wip(self):
        events.register("task:start", "mark_event_as_fired", self)

        now = datetime.datetime.now()
        self.task.update({"real_start_date": None})
        tasks_service.start_task(self.task.id)

        task = Task.get(self.task.id)
        self.assertEqual(task.task_status_id, self.wip_status_id)
        self.assertGreater(task.real_start_date.isoformat(), now.isoformat())
        self.assert_event_is_fired()
示例#8
0
    def test_status_to_wip(self):
        self.task.real_start_date = None
        events.register("task:start", "mark_event_as_fired", self)

        now = datetime.datetime.now()
        self.put("/actions/tasks/%s/start" % self.task.id, {})
        task = self.get("data/tasks/%s" % self.task.id)

        self.assertEqual(task["task_status_id"], self.wip_status_id)
        self.assertGreater(task["real_start_date"], now.isoformat())
        self.assert_event_is_fired()
示例#9
0
 def test_create_asset(self):
     events.register("asset:new", "handle_event", self)
     self.asset_data = {"name": "car", "description": "Test description"}
     path = "data/projects/%s/asset-types/%s/assets/new" % (
         self.project.id, self.entity_type.id)
     asset = self.post(path, self.asset_data)
     assets = asset_info.get_assets()
     self.assertIsNotNone(asset.get("id", None))
     self.assertEquals(len(assets), 1)
     self.assertEquals(assets[0].name, self.asset_data["name"].capitalize())
     self.assertEquals(assets[0].description,
                       self.asset_data["description"])
示例#10
0
    def test_register(self):
        events.register("task:start", "inc_counter", self)
        events.emit("task:start")
        self.assertEqual(self.counter, 2)
        events.emit("task:stop")
        self.assertEqual(self.counter, 2)
        events.emit("task:start")
        self.assertEqual(self.counter, 3)

        event_models = events_service.get_last_events()
        self.assertEquals(len(event_models), 3)
        events.emit("task:start", persist=False)
        event_models = events_service.get_last_events()
        self.assertEquals(len(event_models), 3)
示例#11
0
    def test_create_entry(self):
        events.register("project:new", "handle_event", self)
        create_func = sync_service.create_entry("projects", "project", Project,
                                                "new")
        create_func({"project_id": self.new_project_id})
        self.assertTrue("project_id" in self.last_event_data)
        self.assertIsNotNone(Project.get(self.last_event_data["project_id"]))

        self.last_event_data = {}
        events.unregister_all()
        events.register("project:update", "handle_event", self)
        create_func = sync_service.create_entry("projects", "project", Project,
                                                "update")
        create_func({"project_id": self.new_project_id})
        self.assertTrue("project_id" in self.last_event_data)
        project = Project.get(self.last_event_data["project_id"])
        self.assertEqual(project.name, "Test Sync Project")
示例#12
0
 def test_forward_base_event(self):
     events.register("task:update", "handle_event", self)
     sync_service.forward_base_event("task", "update", {"task_id": "test"})
     self.assertTrue("task_id" in self.last_event_data)