forked from GISGIT/GEE-Python-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_test.py
More file actions
executable file
·48 lines (35 loc) · 1.17 KB
/
Copy pathstring_test.py
File metadata and controls
executable file
·48 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
"""Test for the ee.string module."""
import unittest
import ee
from ee import apitestcase
class StringTest(apitestcase.ApiTestCase):
def testString(self):
"""Verifies basic behavior of ee.String."""
bare_string = ee.String('foo')
self.assertEqual('foo', bare_string.encode())
computed = ee.String('foo').cat('bar')
self.assertTrue(isinstance(computed, ee.String))
self.assertEqual(ee.ApiFunction.lookup('String.cat'), computed.func)
self.assertEqual({
'string1': ee.String('foo'),
'string2': ee.String('bar')
}, computed.args)
# Casting a non-string ComputedObject.
obj = ee.Number(1).add(1)
s = ee.String(obj)
self.assertTrue(isinstance(s, ee.String))
self.assertEqual(ee.ApiFunction.lookup('String'), s.func)
self.assertEqual({'input': obj}, s.args)
def testInternals(self):
"""Test eq(), ne() and hash()."""
a = ee.String('one')
b = ee.String('two')
c = ee.String('one')
self.assertEqual(a, a)
self.assertNotEqual(a, b)
self.assertEqual(a, c)
self.assertNotEqual(b, c)
self.assertNotEqual(hash(a), hash(b))
if __name__ == '__main__':
unittest.main()