Esempio n. 1
0
    def test_creation_with_time(self):
        """
        Test creation of a BackendComment when passing the mtime and the ctime. The passed ctime and mtime
        should be respected since it is important for the correct import of nodes at the AiiDA import/export.
        """
        from aiida.tools.importexport.dbimport.backends.utils import deserialize_attributes

        ctime = deserialize_attributes('2019-02-27T16:20:12.245738', 'date')
        mtime = deserialize_attributes('2019-02-27T16:27:14.798838', 'date')

        comment = self.backend.comments.create(node=self.node,
                                               user=self.user,
                                               content=self.comment_content,
                                               mtime=mtime,
                                               ctime=ctime)

        # Check that the ctime and mtime are the given ones
        self.assertEqual(comment.ctime, ctime)
        self.assertEqual(comment.mtime, mtime)

        comment.store()

        # Check that the given values remain even after storing
        self.assertEqual(comment.ctime, ctime)
        self.assertEqual(comment.mtime, mtime)
Esempio n. 2
0
    def test_creation_with_static_time(self):
        """
        Test creation of a BackendLog when passing the mtime and the ctime. The passed ctime and mtime
        should be respected since it is important for the correct import of nodes at the AiiDA import/export.
        """
        from aiida.tools.importexport.dbimport.backends.utils import deserialize_attributes

        time = deserialize_attributes('2019-02-27T16:20:12.245738', 'date')

        log = self.create_log(time=time)

        # Check that the time is the given one
        self.assertEqual(log.time, time)

        # Store
        self.assertFalse(log.is_stored)
        log.store()
        self.assertTrue(log.is_stored)

        # Check that the given value remains even after storing
        self.assertEqual(log.time, time)