def test_task_exists_and_not_changed(self, title, description, projects,
                                      phids):
     phalerts.process_task(title, description, projects, phids)
     self.phab.project.search.assert_called_once()
     self.phab.maniphest.search.assert_called_once()
     # No tasks should have been created or edited.
     self.phab.maniphest.edit.assert_not_called()
 def test_nonexistent_project(self):
     result = copy.deepcopy(PROJECT_SEARCH_RESULT)
     result["data"] = []
     self.phab.project.search.return_value = result
     with self.assertRaises(phalerts.Error) as cm:
         phalerts.process_task("title", "desc", ["foobar"], [])
     self.assertIn("Could not find project foobar", str(cm.exception))
 def test_task_created(self, title, description, projects, phids):
     """Test that a new task is created."""
     phalerts.process_task(title, description, projects, phids)
     self.phab.project.search.assert_called()
     self.phab.maniphest.search.assert_called_once()
     # Ensure that the task is created.
     self.phab.maniphest.edit.assert_called_once()
     self.assertNotIn("objectIdentifier",
                      self.phab.maniphest.edit.call_args[1].keys())
 def test_task_exists_and_changed(self, title, description, projects,
                                  phids):
     """Test that a task will be changed if description is different."""
     phalerts.process_task(title, description, projects, phids)
     self.phab.project.search.assert_called()
     self.phab.maniphest.search.assert_called_once()
     # Ensure that the task has been edited (rather than created, which uses
     # the same maniphest.edit API endpoint).
     self.phab.maniphest.edit.assert_called_once()
     self.assertIn("objectIdentifier",
                   self.phab.maniphest.edit.call_args[1].keys())
 def test_task_creation_failed(self):
     self.phab.maniphest.edit.return_value = {}
     with self.assertRaises(phalerts.Error):
         phalerts.process_task("new title", "new description", [], [])