Exemplo n.º 1
0
 async def test_correct_data_is_set_to_json_when_replacing(self):
     """Test operator replaces object and adds necessary info."""
     operator = Operator(self.client)
     with patch(
         "metadata_backend.api.operators.Operator._replace_object_from_db", return_value=self.accession_id
     ) as mocked_insert:
         with patch("metadata_backend.api.operators.datetime") as m_date:
             m_date.utcnow.return_value = datetime.datetime(2020, 4, 14)
             acc = await (operator._format_data_to_replace_and_add_to_db("study", self.accession_id, {}))
             mocked_insert.assert_called_once_with(
                 "study",
                 self.accession_id,
                 {"accessionId": self.accession_id, "dateModified": datetime.datetime(2020, 4, 14)},
             )
         self.assertEqual(acc, self.accession_id)
Exemplo n.º 2
0
 async def test_wront_data_is_set_to_json_when_replacing(self):
     """Test operator replace catches error."""
     operator = Operator(self.client)
     with patch("metadata_backend.api.operators.Operator._replace_object_from_db", return_value=self.accession_id):
         with patch("metadata_backend.api.operators.datetime") as m_date:
             m_date.utcnow.return_value = datetime.datetime(2020, 4, 14)
             with self.assertRaises(HTTPBadRequest):
                 await (
                     operator._format_data_to_replace_and_add_to_db(
                         "study",
                         self.accession_id,
                         {
                             "accessionId": self.accession_id,
                             "dateCreated": datetime.datetime(2020, 4, 14),
                             "dateModified": datetime.datetime(2020, 4, 14),
                             "publishDate": datetime.datetime(2020, 6, 14),
                         },
                     )
                 )