Esempio n. 1
0
    def test_creation_with_time(self):
        """
        Test creation of a BackendNode 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.utils import deserialize_attributes

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

        node = self.backend.nodes.create(node_type=self.node_type,
                                         user=self.user,
                                         label=self.node_label,
                                         description=self.node_description,
                                         mtime=mtime,
                                         ctime=ctime)

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

        node.store()

        # Check that the given values remain even after storing
        self.assertEqual(node.ctime, ctime)
        self.assertEqual(node.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.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)