Exemple #1
0
 def test_duration_array(self):
     self.assert_supports_temporal_types()
     with self.driver.session() as session:
         data = [Duration(1, 2, 3, 4, 5, 6), Duration(9, 8, 7, 6, 5, 4)]
         value = session.write_transaction(run_and_rollback,
                                           "CREATE (a {x:$x}) RETURN a.x",
                                           x=data)
         self.assertEqual(value, data)
Exemple #2
0
 def test_nanosecond_resolution_duration(self):
     self.assert_supports_temporal_types()
     with self.driver.session() as session:
         result = session.run("RETURN duration('P1Y2M3DT4H5M6.789123456S')")
         value = result.single().value()
         self.assertIsInstance(value, Duration)
         self.assertEqual(value, Duration(years=1, months=2, days=3, hours=4, minutes=5, seconds=6.789123456))
Exemple #3
0
 def test_mixed_array(self):
     self.assert_supports_temporal_types()
     with self.driver.session() as session:
         data = [Date(1976, 6, 13), Duration(9, 8, 7, 6, 5, 4)]
         with self.assertRaises(CypherTypeError):
             _ = session.write_transaction(run_and_rollback,
                                           "CREATE (a {x:$x}) RETURN a.x",
                                           x=data)
Exemple #4
0
 def test_duration(self):
     self.assert_supports_temporal_types()
     with self.driver.session() as session:
         result = session.run("CYPHER runtime=interpreted WITH $x AS x "
                              "RETURN x.months, x.days, x.seconds, x.microsecondsOfSecond",
                              x=Duration(years=1, months=2, days=3, hours=4, minutes=5, seconds=6.789012))
         months, days, seconds, microseconds = result.single()
         self.assertEqual(months, 14)
         self.assertEqual(days, 3)
         self.assertEqual(seconds, 14706)
         self.assertEqual(microseconds, 789012)