MCPcopy
hub / github.com/google/earthengine-api / test_date

Method test_date

python/ee/tests/ee_date_test.py:38–75  ·  view source on GitHub ↗

Verifies date constructors.

(self)

Source from the content-addressed store, hash-verified

36class DateTest(apitestcase.ApiTestCase):
37
38 def test_date(self):
39 """Verifies date constructors."""
40
41 datefunc = ee.ApiFunction.lookup('Date')
42
43 d1 = ee.Date('2000-01-01')
44 d2 = ee.Date(946684800000)
45 d3 = ee.Date(datetime.datetime(2000, 1, 1))
46 d4 = ee.Date(d3)
47 dates = [d1, d2, d3, d4]
48
49 for d in dates:
50 self.assertIsInstance(d, ee.Date)
51 self.assertEqual(datefunc, d.func)
52
53 self.assertEqual(d1.args, {'value': '2000-01-01'})
54 for d in dates[1:]:
55 self.assertEqual(d.args['value'], 946684800000)
56
57 d5 = ee.Date(ee.CustomFunction.variable('Date', 'foo'))
58 self.assertIsInstance(d5, ee.Date)
59 self.assertTrue(d5.isVariable())
60 self.assertEqual('foo', d5.varName)
61
62 # A non-date variable.
63 v = ee.CustomFunction.variable('Number', 'bar')
64 d6 = ee.Date(v)
65 self.assertIsInstance(d6, ee.Date)
66 self.assertFalse(d6.isVariable())
67 self.assertEqual(datefunc, d6.func)
68 self.assertEqual({'value': v}, d6.args)
69
70 # A non-date ComputedObject, promotion and casting.
71 obj = ee.ApiFunction.call_('DateRange', 1, 2)
72 d7 = ee.Date(obj)
73 self.assertIsInstance(d7, ee.Date)
74 self.assertEqual(datefunc, d7.func)
75 self.assertEqual({'value': obj}, d7.args)
76
77 def test_date_is_not_valid(self):
78 message = r'Invalid argument specified for ee.Date\(\): \[\'a list\']'

Callers

nothing calls this directly

Calls 4

lookupMethod · 0.80
variableMethod · 0.80
isVariableMethod · 0.80
call_Method · 0.80

Tested by

no test coverage detected