Пример #1
0
 def test_patch_journal_issues_returns_204_if_issue_already_exists(self):
     self.request.matchdict["journal_id"] = "1678-4596-cr"
     commands_data = (
         ("add_issue_to_journal", {
             "issue": "1678-4596-cr-25-3"
         }),
         ("insert_issue_to_journal", {
             "issue": "1678-4596-cr-25-3",
             "index": 2
         }),
     )
     for command, data in commands_data:
         with self.subTest(command=command, data=data):
             self.request.validated = data
             MockPatchJournal = Mock(
                 side_effect=exceptions.AlreadyExists("Already Exists"))
             self.request.services[command] = MockPatchJournal
             response = restfulapi.patch_journal_issues(self.request)
             self.assertIsInstance(response, HTTPNoContent)
Пример #2
0
 def add(self, data):
     id = data.id()
     if id in self._data_store:
         raise exceptions.AlreadyExists()
     else:
         self.update(data)
Пример #3
0
    def add(self, change: dict):

        if change["timestamp"] in self._data_store:
            raise exceptions.AlreadyExists()
        else:
            self._data_store[change["timestamp"]] = change