earthengine-api 1.6.11rc0__py3-none-any.whl → 1.6.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/METADATA +1 -1
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/RECORD +48 -46
- ee/__init__.py +5 -5
- ee/_cloud_api_utils.py +33 -10
- ee/_state.py +105 -0
- ee/apifunction.py +1 -1
- ee/apitestcase.py +15 -21
- ee/batch.py +1 -1
- ee/cli/commands.py +153 -63
- ee/cli/eecli.py +1 -1
- ee/cli/utils.py +25 -15
- ee/collection.py +27 -18
- ee/computedobject.py +5 -5
- ee/customfunction.py +3 -3
- ee/data.py +104 -210
- ee/ee_array.py +4 -2
- ee/ee_number.py +1 -1
- ee/ee_string.py +18 -26
- ee/ee_types.py +2 -2
- ee/element.py +1 -1
- ee/featurecollection.py +10 -7
- ee/filter.py +2 -2
- ee/geometry.py +20 -21
- ee/image.py +7 -12
- ee/imagecollection.py +3 -3
- ee/mapclient.py +9 -9
- ee/oauth.py +13 -6
- ee/tests/_cloud_api_utils_test.py +16 -0
- ee/tests/_helpers_test.py +9 -9
- ee/tests/_state_test.py +49 -0
- ee/tests/apifunction_test.py +5 -5
- ee/tests/batch_test.py +61 -50
- ee/tests/collection_test.py +13 -13
- ee/tests/data_test.py +65 -60
- ee/tests/dictionary_test.py +9 -9
- ee/tests/ee_number_test.py +32 -26
- ee/tests/ee_string_test.py +8 -0
- ee/tests/ee_test.py +37 -19
- ee/tests/element_test.py +2 -2
- ee/tests/feature_test.py +6 -6
- ee/tests/function_test.py +5 -5
- ee/tests/geometry_test.py +73 -51
- ee/tests/oauth_test.py +21 -2
- ee/tests/serializer_test.py +8 -8
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/WHEEL +0 -0
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/entry_points.txt +0 -0
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/licenses/LICENSE +0 -0
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/top_level.txt +0 -0
ee/tests/_state_test.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Tests for ee._state."""
|
|
3
|
+
|
|
4
|
+
from absl.testing import parameterized
|
|
5
|
+
|
|
6
|
+
import unittest
|
|
7
|
+
from ee import _state
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class StateTest(parameterized.TestCase):
|
|
11
|
+
|
|
12
|
+
def setUp(self):
|
|
13
|
+
super().setUp()
|
|
14
|
+
_state.reset_state()
|
|
15
|
+
|
|
16
|
+
@parameterized.named_parameters(
|
|
17
|
+
('global_mode', False),
|
|
18
|
+
)
|
|
19
|
+
def test_get_state(self, use_context_mode: bool):
|
|
20
|
+
state = _state.get_state()
|
|
21
|
+
|
|
22
|
+
self.assertIsInstance(state, _state.EEState)
|
|
23
|
+
self.assertEqual(state, _state.EEState())
|
|
24
|
+
|
|
25
|
+
@parameterized.named_parameters(
|
|
26
|
+
('global_mode', False),
|
|
27
|
+
)
|
|
28
|
+
def test_update_state(self, use_context_mode: bool):
|
|
29
|
+
state = _state.get_state()
|
|
30
|
+
|
|
31
|
+
# Modify the state and verify the global state has been updated.
|
|
32
|
+
state.cloud_api_user_project = 'my-project'
|
|
33
|
+
|
|
34
|
+
self.assertEqual(_state.get_state().cloud_api_user_project, 'my-project')
|
|
35
|
+
|
|
36
|
+
@parameterized.named_parameters(
|
|
37
|
+
('global_mode', False),
|
|
38
|
+
)
|
|
39
|
+
def test_reset_state(self, use_context_mode: bool):
|
|
40
|
+
state = _state.get_state()
|
|
41
|
+
state.cloud_api_user_project = 'my-project'
|
|
42
|
+
|
|
43
|
+
_state.reset_state()
|
|
44
|
+
|
|
45
|
+
self.assertEqual(_state.get_state(), _state.EEState())
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == '__main__':
|
|
49
|
+
unittest.main()
|
ee/tests/apifunction_test.py
CHANGED
|
@@ -10,7 +10,7 @@ from ee import apitestcase
|
|
|
10
10
|
|
|
11
11
|
class ApiFunctionTest(apitestcase.ApiTestCase):
|
|
12
12
|
|
|
13
|
-
def
|
|
13
|
+
def test_add_functions(self):
|
|
14
14
|
"""Verifies that addition of static and instance API functions."""
|
|
15
15
|
|
|
16
16
|
# Check instance vs static functions, and trampling of
|
|
@@ -48,7 +48,7 @@ class ApiFunctionTest(apitestcase.ApiTestCase):
|
|
|
48
48
|
self.assertTrue(hasattr(TestClass, 'pre_addBands'))
|
|
49
49
|
self.assertFalse(hasattr(TestClass, '_pre_addBands'))
|
|
50
50
|
|
|
51
|
-
def
|
|
51
|
+
def test_add_functions_inherited(self):
|
|
52
52
|
"""Verifies that inherited non-client functions can be overridden."""
|
|
53
53
|
|
|
54
54
|
class Base:
|
|
@@ -66,7 +66,7 @@ class ApiFunctionTest(apitestcase.ApiTestCase):
|
|
|
66
66
|
self.assertNotEqual(Base.addBands, Child.addBands)
|
|
67
67
|
# pytype: enable=attribute-error
|
|
68
68
|
|
|
69
|
-
def
|
|
69
|
+
def test_eq(self):
|
|
70
70
|
a_signature = {'hello': 'world', 'args': []}
|
|
71
71
|
b_signature = {
|
|
72
72
|
'hello': 'world',
|
|
@@ -93,14 +93,14 @@ class ApiFunctionTest(apitestcase.ApiTestCase):
|
|
|
93
93
|
ee.ApiFunction(name='test', signature=a_signature), a_signature
|
|
94
94
|
)
|
|
95
95
|
|
|
96
|
-
def
|
|
96
|
+
def test_init_opt_params(self):
|
|
97
97
|
signature = {'hello': 'world', 'args': []}
|
|
98
98
|
self.assertEqual(
|
|
99
99
|
ee.ApiFunction(name='test', signature=signature),
|
|
100
100
|
ee.ApiFunction(name='test', opt_signature=signature),
|
|
101
101
|
)
|
|
102
102
|
|
|
103
|
-
def
|
|
103
|
+
def test_import_api_opt_params(self):
|
|
104
104
|
args = dict(
|
|
105
105
|
target=ee.Dictionary, prefix='Dictionary', type_name='Dictionary'
|
|
106
106
|
)
|
ee/tests/batch_test.py
CHANGED
|
@@ -8,6 +8,7 @@ from unittest import mock
|
|
|
8
8
|
|
|
9
9
|
import unittest
|
|
10
10
|
import ee
|
|
11
|
+
from ee import _state
|
|
11
12
|
from ee import apitestcase
|
|
12
13
|
from ee import batch
|
|
13
14
|
from ee import data
|
|
@@ -55,15 +56,25 @@ class TaskTest(unittest.TestCase):
|
|
|
55
56
|
|
|
56
57
|
def setUp(self):
|
|
57
58
|
super().setUp()
|
|
58
|
-
|
|
59
|
+
mock.patch.object(
|
|
60
|
+
_state,
|
|
61
|
+
'get_state',
|
|
62
|
+
return_value=_state.EEState(
|
|
63
|
+
initialized=True, cloud_api_user_project='test-project'
|
|
64
|
+
),
|
|
65
|
+
).start()
|
|
66
|
+
|
|
67
|
+
def tearDown(self):
|
|
68
|
+
super().tearDown()
|
|
69
|
+
mock.patch.stopall()
|
|
59
70
|
|
|
60
|
-
def
|
|
71
|
+
def test_start_without_config(self):
|
|
61
72
|
task = batch.Task('an id', 'a task type', 'a state')
|
|
62
73
|
self.assertIsNone(task.config)
|
|
63
74
|
with self.assertRaisesRegex(ee.EEException, 'Task config'):
|
|
64
75
|
task.start()
|
|
65
76
|
|
|
66
|
-
def
|
|
77
|
+
def test_start_unknown_task_type(self):
|
|
67
78
|
task_type = 'bad task type'
|
|
68
79
|
task = batch.Task('an id', task_type, 'a state', {'some': 'value'})
|
|
69
80
|
with self.assertRaisesRegex(
|
|
@@ -71,7 +82,7 @@ class TaskTest(unittest.TestCase):
|
|
|
71
82
|
):
|
|
72
83
|
task.start()
|
|
73
84
|
|
|
74
|
-
def
|
|
85
|
+
def test_status_with_id(self):
|
|
75
86
|
name = 'projects/test-project/operations/test_1'
|
|
76
87
|
task = batch.Task('an id', 'a task type', 'a state', name=name)
|
|
77
88
|
with mock.patch.object(
|
|
@@ -82,7 +93,7 @@ class TaskTest(unittest.TestCase):
|
|
|
82
93
|
m.call_args.args[0], 'projects/test-project/operations/test_1'
|
|
83
94
|
)
|
|
84
95
|
|
|
85
|
-
def
|
|
96
|
+
def test_status_with_name(self):
|
|
86
97
|
task = batch.Task(
|
|
87
98
|
None,
|
|
88
99
|
'a task type',
|
|
@@ -97,7 +108,7 @@ class TaskTest(unittest.TestCase):
|
|
|
97
108
|
m.call_args.args[0], 'projects/test-project/operations/test_1'
|
|
98
109
|
)
|
|
99
110
|
|
|
100
|
-
def
|
|
111
|
+
def test_status_with_id_state_unknown(self):
|
|
101
112
|
name = 'projects/test-project/operations/an id'
|
|
102
113
|
task = batch.Task('an id', 'a task type', 'a state', name=name)
|
|
103
114
|
with mock.patch.object(
|
|
@@ -108,11 +119,11 @@ class TaskTest(unittest.TestCase):
|
|
|
108
119
|
m.call_args.args[0], 'projects/test-project/operations/an id'
|
|
109
120
|
)
|
|
110
121
|
|
|
111
|
-
def
|
|
122
|
+
def test_status_without_id_or_name(self):
|
|
112
123
|
task = batch.Task(None, 'a task type', 'a state')
|
|
113
124
|
self.assertEqual('UNSUBMITTED', task.status()['state'])
|
|
114
125
|
|
|
115
|
-
def
|
|
126
|
+
def test_active(self):
|
|
116
127
|
name = 'projects/test-project/operations/an id'
|
|
117
128
|
task = batch.Task('an id', 'a task type', 'a state', name=name)
|
|
118
129
|
with mock.patch.object(
|
|
@@ -120,18 +131,18 @@ class TaskTest(unittest.TestCase):
|
|
|
120
131
|
):
|
|
121
132
|
self.assertTrue(task.active())
|
|
122
133
|
|
|
123
|
-
def
|
|
134
|
+
def test_not_active(self):
|
|
124
135
|
task = batch.Task('an id', 'a task type', 'a state')
|
|
125
136
|
with mock.patch.object(
|
|
126
137
|
data, 'getOperation', return_value=SUCCEEDED_OPERATION
|
|
127
138
|
):
|
|
128
139
|
self.assertFalse(task.active())
|
|
129
140
|
|
|
130
|
-
def
|
|
141
|
+
def test_repr_without_config(self):
|
|
131
142
|
task = batch.Task('an id', 'a task type', 'a state')
|
|
132
143
|
self.assertEqual('<Task "an id">', task.__repr__())
|
|
133
144
|
|
|
134
|
-
def
|
|
145
|
+
def test_repr_with_config(self):
|
|
135
146
|
an_id = None
|
|
136
147
|
task_type = 'a task type'
|
|
137
148
|
state = 'a state'
|
|
@@ -143,7 +154,7 @@ class TaskTest(unittest.TestCase):
|
|
|
143
154
|
f'<Task {task_type}: {description} ({state})>', task.__repr__()
|
|
144
155
|
)
|
|
145
156
|
|
|
146
|
-
def
|
|
157
|
+
def test_repr_with_id_and_config(self):
|
|
147
158
|
an_id = 'an id'
|
|
148
159
|
task_type = 'a task type'
|
|
149
160
|
state = 'a state'
|
|
@@ -158,23 +169,23 @@ class TaskTest(unittest.TestCase):
|
|
|
158
169
|
|
|
159
170
|
class ExportTest(unittest.TestCase):
|
|
160
171
|
|
|
161
|
-
def
|
|
172
|
+
def test_export_cannot_init(self):
|
|
162
173
|
with self.assertRaises(AssertionError):
|
|
163
174
|
batch.Export()
|
|
164
175
|
|
|
165
|
-
def
|
|
176
|
+
def test_export_image_cannot_init(self):
|
|
166
177
|
with self.assertRaises(AssertionError):
|
|
167
178
|
batch.Export.image.__init__('something')
|
|
168
179
|
|
|
169
|
-
def
|
|
180
|
+
def test_export_map_cannot_init(self):
|
|
170
181
|
with self.assertRaises(AssertionError):
|
|
171
182
|
batch.Export.map.__init__('something')
|
|
172
183
|
|
|
173
|
-
def
|
|
184
|
+
def test_export_table_cannot_init(self):
|
|
174
185
|
with self.assertRaises(AssertionError):
|
|
175
186
|
batch.Export.table.__init__('something')
|
|
176
187
|
|
|
177
|
-
def
|
|
188
|
+
def test_export_video_cannot_init(self):
|
|
178
189
|
with self.assertRaises(AssertionError):
|
|
179
190
|
batch.Export.video.__init__('something')
|
|
180
191
|
|
|
@@ -191,7 +202,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
191
202
|
self.start_call_params = None
|
|
192
203
|
self.update_call_params = None
|
|
193
204
|
|
|
194
|
-
def
|
|
205
|
+
def test_task_start_cloud_api(self):
|
|
195
206
|
"""Verifies that Task.start() calls the server appropriately."""
|
|
196
207
|
mock_cloud_api_resource = mock.MagicMock()
|
|
197
208
|
mock_cloud_api_resource.projects().table().export().execute.return_value = {
|
|
@@ -206,7 +217,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
206
217
|
self.assertTrue(export_args[1]['body']['requestId'])
|
|
207
218
|
self.assertEqual(export_args[1]['body']['description'], 'bar')
|
|
208
219
|
|
|
209
|
-
def
|
|
220
|
+
def test_task_cancel_cloud_api(self):
|
|
210
221
|
mock_cloud_api_resource = mock.MagicMock()
|
|
211
222
|
mock_cloud_api_resource.projects().operations().list().execute.return_value = {
|
|
212
223
|
'operations': [{
|
|
@@ -227,7 +238,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
227
238
|
cancel_args[1]['name'], 'projects/earthengine-legacy/operations/TEST1'
|
|
228
239
|
)
|
|
229
240
|
|
|
230
|
-
def
|
|
241
|
+
def test_export_image_trivial_region_cloud_api(self):
|
|
231
242
|
"""Verifies the task created by Export.image() with a trivial region."""
|
|
232
243
|
with apitestcase.UsingCloudApi():
|
|
233
244
|
region = [0, 0, 1, 0, 1, 1]
|
|
@@ -262,7 +273,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
262
273
|
task.config,
|
|
263
274
|
)
|
|
264
275
|
|
|
265
|
-
def
|
|
276
|
+
def test_export_image_cloud_api(self):
|
|
266
277
|
"""Verifies the task created by Export.image()."""
|
|
267
278
|
with apitestcase.UsingCloudApi():
|
|
268
279
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -305,7 +316,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
305
316
|
task.config,
|
|
306
317
|
)
|
|
307
318
|
|
|
308
|
-
def
|
|
319
|
+
def test_export_image_cloud_api_invalid_skip_empty_tiles(self):
|
|
309
320
|
"""Verifies errors are thrown when incorrectly specifying skipEmptyTiles."""
|
|
310
321
|
with apitestcase.UsingCloudApi():
|
|
311
322
|
with self.assertRaisesRegex(
|
|
@@ -318,7 +329,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
318
329
|
skipEmptyTiles=True,
|
|
319
330
|
)
|
|
320
331
|
|
|
321
|
-
def
|
|
332
|
+
def test_export_image_with_tf_record_cloud_api(self):
|
|
322
333
|
"""Verifies the task created by Export.image()."""
|
|
323
334
|
with apitestcase.UsingCloudApi():
|
|
324
335
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -377,7 +388,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
377
388
|
task.config,
|
|
378
389
|
)
|
|
379
390
|
|
|
380
|
-
def
|
|
391
|
+
def test_export_image_to_asset_cloud_api(self):
|
|
381
392
|
"""Verifies the Asset export task created by Export.image.toAsset()."""
|
|
382
393
|
with apitestcase.UsingCloudApi():
|
|
383
394
|
config = dict(
|
|
@@ -441,7 +452,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
441
452
|
task_ordered.config,
|
|
442
453
|
)
|
|
443
454
|
|
|
444
|
-
def
|
|
455
|
+
def test_export_image_to_asset_cloud_api_with_tile_size(self):
|
|
445
456
|
"""Verifies the Asset export task created by Export.image.toAsset()."""
|
|
446
457
|
with apitestcase.UsingCloudApi():
|
|
447
458
|
config = dict(
|
|
@@ -479,7 +490,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
479
490
|
task_ordered.config,
|
|
480
491
|
)
|
|
481
492
|
|
|
482
|
-
def
|
|
493
|
+
def test_export_image_to_cloud_storage_cloud_api(self):
|
|
483
494
|
"""Verifies the Cloud Storage export task created by Export.image()."""
|
|
484
495
|
with apitestcase.UsingCloudApi():
|
|
485
496
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -573,7 +584,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
573
584
|
task_with_priority.config,
|
|
574
585
|
)
|
|
575
586
|
|
|
576
|
-
def
|
|
587
|
+
def test_export_image_to_google_drive_cloud_api(self):
|
|
577
588
|
"""Verifies the Drive destined task created by Export.image.toDrive()."""
|
|
578
589
|
with apitestcase.UsingCloudApi():
|
|
579
590
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -679,7 +690,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
679
690
|
drive_task_with_priority.config,
|
|
680
691
|
)
|
|
681
692
|
|
|
682
|
-
def
|
|
693
|
+
def test_export_map_to_cloud_storage_cloud_api(self):
|
|
683
694
|
"""Verifies the task created by Export.map.toCloudStorage()."""
|
|
684
695
|
with apitestcase.UsingCloudApi():
|
|
685
696
|
config = dict(
|
|
@@ -812,7 +823,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
812
823
|
task_with_priority.config,
|
|
813
824
|
)
|
|
814
825
|
|
|
815
|
-
def
|
|
826
|
+
def test_export_map_to_cloud_storage_cloud_api_with_v1_parameters(self):
|
|
816
827
|
"""Verifies Export.map.toCloudStorage() tasks with v1 parameters."""
|
|
817
828
|
with apitestcase.UsingCloudApi():
|
|
818
829
|
config = dict(
|
|
@@ -868,7 +879,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
868
879
|
task_keyed.config,
|
|
869
880
|
)
|
|
870
881
|
|
|
871
|
-
def
|
|
882
|
+
def test_export_map_to_cloud_storage_cloud_api_with_v1alpha_parameters(self):
|
|
872
883
|
"""Verifies Export.map.toCloudStorage() tasks with v1alpha parameters."""
|
|
873
884
|
with apitestcase.UsingCloudApi():
|
|
874
885
|
task_keyed = ee.batch.Export.map.toCloudStorage(
|
|
@@ -897,7 +908,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
897
908
|
task_keyed.config,
|
|
898
909
|
)
|
|
899
910
|
|
|
900
|
-
def
|
|
911
|
+
def test_export_table_cloud_api(self):
|
|
901
912
|
"""Verifies the task created by Export.table()."""
|
|
902
913
|
with apitestcase.UsingCloudApi():
|
|
903
914
|
task = ee.batch.Export.table(
|
|
@@ -922,7 +933,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
922
933
|
task.config,
|
|
923
934
|
)
|
|
924
935
|
|
|
925
|
-
def
|
|
936
|
+
def test_export_table_cloud_api_bogus_parameter(self):
|
|
926
937
|
"""Verifies that bogus parameters are rejected."""
|
|
927
938
|
with apitestcase.UsingCloudApi():
|
|
928
939
|
with self.assertRaisesRegex(
|
|
@@ -932,7 +943,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
932
943
|
ee.FeatureCollection('drive test FC'), framesPerSecond=30
|
|
933
944
|
)
|
|
934
945
|
|
|
935
|
-
def
|
|
946
|
+
def test_export_table_selectors_cloud_api(self):
|
|
936
947
|
"""Verifies that table export accepts a list or tuple of selectors."""
|
|
937
948
|
with apitestcase.UsingCloudApi():
|
|
938
949
|
task = ee.batch.Export.table.toCloudStorage(
|
|
@@ -955,7 +966,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
955
966
|
)
|
|
956
967
|
self.assertEqual(['ab', 'cd', 'ef'], task.config['selectors'])
|
|
957
968
|
|
|
958
|
-
def
|
|
969
|
+
def test_export_table_to_cloud_storage_cloud_api(self):
|
|
959
970
|
"""Verifies the Cloud Storage task created by Export.table()."""
|
|
960
971
|
with apitestcase.UsingCloudApi():
|
|
961
972
|
task = ee.batch.Export.table.toCloudStorage(
|
|
@@ -1006,7 +1017,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1006
1017
|
task_with_priority.config,
|
|
1007
1018
|
)
|
|
1008
1019
|
|
|
1009
|
-
def
|
|
1020
|
+
def test_export_table_to_google_drive_cloud_api(self):
|
|
1010
1021
|
"""Verifies the Drive destined task created by Export.table.toDrive()."""
|
|
1011
1022
|
with apitestcase.UsingCloudApi():
|
|
1012
1023
|
test_collection = ee.FeatureCollection('foo')
|
|
@@ -1093,7 +1104,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1093
1104
|
)
|
|
1094
1105
|
self.assertEqual(expected_config_with_priority, task_with_priority.config)
|
|
1095
1106
|
|
|
1096
|
-
def
|
|
1107
|
+
def test_export_table_to_asset_cloud_api(self):
|
|
1097
1108
|
"""Verifies the export task created by Export.table.toAsset()."""
|
|
1098
1109
|
with apitestcase.UsingCloudApi():
|
|
1099
1110
|
task = ee.batch.Export.table.toAsset(
|
|
@@ -1141,7 +1152,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1141
1152
|
task_with_priority.config,
|
|
1142
1153
|
)
|
|
1143
1154
|
|
|
1144
|
-
def
|
|
1155
|
+
def test_export_table_with_file_format_cloud_api(self):
|
|
1145
1156
|
"""Verifies the task created by Export.table() given a file format."""
|
|
1146
1157
|
with apitestcase.UsingCloudApi():
|
|
1147
1158
|
task = ee.batch.Export.table.toCloudStorage(
|
|
@@ -1168,7 +1179,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1168
1179
|
task.config,
|
|
1169
1180
|
)
|
|
1170
1181
|
|
|
1171
|
-
def
|
|
1182
|
+
def test_export_table_to_feature_view_cloud_api(self):
|
|
1172
1183
|
"""Verifies the export task created by Export.table.toFeatureView()."""
|
|
1173
1184
|
with apitestcase.UsingCloudApi():
|
|
1174
1185
|
task = ee.batch.Export.table.toFeatureView(
|
|
@@ -1231,7 +1242,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1231
1242
|
task_with_priority.config,
|
|
1232
1243
|
)
|
|
1233
1244
|
|
|
1234
|
-
def
|
|
1245
|
+
def test_export_table_to_feature_view_empty_params_cloud_api(self):
|
|
1235
1246
|
"""Verifies the export task created by Export.table.toFeatureView()."""
|
|
1236
1247
|
with apitestcase.UsingCloudApi():
|
|
1237
1248
|
task = ee.batch.Export.table.toFeatureView(
|
|
@@ -1263,7 +1274,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1263
1274
|
task.config,
|
|
1264
1275
|
)
|
|
1265
1276
|
|
|
1266
|
-
def
|
|
1277
|
+
def test_export_table_to_feature_view_all_ingestion_params(self):
|
|
1267
1278
|
"""Verifies the task ingestion params created by toFeatureView()."""
|
|
1268
1279
|
task = ee.batch.Export.table.toFeatureView(
|
|
1269
1280
|
collection=ee.FeatureCollection('foo'),
|
|
@@ -1309,7 +1320,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1309
1320
|
task.config['featureViewExportOptions']['ingestionTimeParameters'],
|
|
1310
1321
|
)
|
|
1311
1322
|
|
|
1312
|
-
def
|
|
1323
|
+
def test_export_table_to_feature_view_bad_rank_by_one_thing_rule(self):
|
|
1313
1324
|
"""Verifies a bad RankByOneThingRule throws an exception."""
|
|
1314
1325
|
with self.assertRaisesRegex(
|
|
1315
1326
|
ee.EEException, 'Ranking rule format is invalid.*'
|
|
@@ -1320,7 +1331,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1320
1331
|
ingestionTimeParameters={'thinningRanking': 'my-attribute BAD_DIR'},
|
|
1321
1332
|
)
|
|
1322
1333
|
|
|
1323
|
-
def
|
|
1334
|
+
def test_export_table_to_feature_view_bad_ranking_rule(self):
|
|
1324
1335
|
"""Verifies a bad RankingRule throws an exception."""
|
|
1325
1336
|
with self.assertRaisesRegex(
|
|
1326
1337
|
ee.EEException, 'Unable to build ranking rule from rules.*'
|
|
@@ -1331,7 +1342,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1331
1342
|
ingestionTimeParameters={'thinningRanking': {'key': 'val'}},
|
|
1332
1343
|
)
|
|
1333
1344
|
|
|
1334
|
-
def
|
|
1345
|
+
def test_export_table_to_feature_view_bad_ingestion_time_params(self):
|
|
1335
1346
|
"""Verifies a bad set of ingestion time params throws an exception."""
|
|
1336
1347
|
with self.assertRaisesRegex(
|
|
1337
1348
|
ee.EEException,
|
|
@@ -1346,7 +1357,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1346
1357
|
ingestionTimeParameters={'badThinningKey': {'key': 'val'}},
|
|
1347
1358
|
)
|
|
1348
1359
|
|
|
1349
|
-
def
|
|
1360
|
+
def test_export_table_to_big_query_required_params(self):
|
|
1350
1361
|
"""Verifies the export task created by Export.table.toBigQuery()."""
|
|
1351
1362
|
with apitestcase.UsingCloudApi():
|
|
1352
1363
|
task = ee.batch.Export.table.toBigQuery(
|
|
@@ -1399,7 +1410,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1399
1410
|
task_with_priority.config,
|
|
1400
1411
|
)
|
|
1401
1412
|
|
|
1402
|
-
def
|
|
1413
|
+
def test_export_table_to_big_query_all_params(self):
|
|
1403
1414
|
"""Verifies the export task created by Export.table.toBigQuery()."""
|
|
1404
1415
|
with apitestcase.UsingCloudApi():
|
|
1405
1416
|
task = ee.batch.Export.table.toBigQuery(
|
|
@@ -1436,7 +1447,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1436
1447
|
task.config,
|
|
1437
1448
|
)
|
|
1438
1449
|
|
|
1439
|
-
def
|
|
1450
|
+
def test_export_table_to_big_query_bad_table_name(self):
|
|
1440
1451
|
"""Verifies a bad table name throws an exception."""
|
|
1441
1452
|
with apitestcase.UsingCloudApi():
|
|
1442
1453
|
with self.assertRaisesRegex(
|
|
@@ -1459,7 +1470,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1459
1470
|
description='foo',
|
|
1460
1471
|
)
|
|
1461
1472
|
|
|
1462
|
-
def
|
|
1473
|
+
def test_export_video_cloud_api(self):
|
|
1463
1474
|
"""Verifies the task created by Export.video()."""
|
|
1464
1475
|
with apitestcase.UsingCloudApi():
|
|
1465
1476
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -1549,7 +1560,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1549
1560
|
collection, 'TestVideoName', config_with_bogus_option
|
|
1550
1561
|
)
|
|
1551
1562
|
|
|
1552
|
-
def
|
|
1563
|
+
def test_export_video_to_cloud_storage_cloud_api(self):
|
|
1553
1564
|
"""Verifies the task created by Export.video.toCloudStorage()."""
|
|
1554
1565
|
with apitestcase.UsingCloudApi():
|
|
1555
1566
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -1644,7 +1655,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1644
1655
|
)
|
|
1645
1656
|
self.assertEqual(expected_config_with_priority, task_with_priority.config)
|
|
1646
1657
|
|
|
1647
|
-
def
|
|
1658
|
+
def test_export_video_to_drive_cloud_api(self):
|
|
1648
1659
|
"""Verifies the task created by Export.video.toDrive()."""
|
|
1649
1660
|
with apitestcase.UsingCloudApi():
|
|
1650
1661
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -1737,7 +1748,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1737
1748
|
)
|
|
1738
1749
|
self.assertEqual(expected_config_with_priority, task_with_priority.config)
|
|
1739
1750
|
|
|
1740
|
-
def
|
|
1751
|
+
def test_export_workload_tag(self):
|
|
1741
1752
|
"""Verifies that the workload tag state is captured before start."""
|
|
1742
1753
|
mock_cloud_api_resource = mock.MagicMock()
|
|
1743
1754
|
mock_cloud_api_resource.projects().table().export().execute.return_value = {
|
ee/tests/collection_test.py
CHANGED
|
@@ -11,7 +11,7 @@ from ee import apitestcase
|
|
|
11
11
|
|
|
12
12
|
class CollectionTestCase(apitestcase.ApiTestCase):
|
|
13
13
|
|
|
14
|
-
def
|
|
14
|
+
def test_sort_and_limit(self):
|
|
15
15
|
"""Verifies the behavior of the sort() and limit() methods."""
|
|
16
16
|
collection = ee.Collection(ee.Function(), {})
|
|
17
17
|
|
|
@@ -41,7 +41,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
41
41
|
'ascending': False
|
|
42
42
|
}, reverse_sorted_collection.args)
|
|
43
43
|
|
|
44
|
-
def
|
|
44
|
+
def test_filter(self):
|
|
45
45
|
"""Verifies the behavior of filter() method."""
|
|
46
46
|
collection = ee.Collection(ee.Function(), {})
|
|
47
47
|
|
|
@@ -56,7 +56,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
56
56
|
}, filtered.args)
|
|
57
57
|
self.assertIsInstance(filtered, ee.Collection)
|
|
58
58
|
|
|
59
|
-
def
|
|
59
|
+
def test_filter_shortcuts(self):
|
|
60
60
|
"""Verifies the behavior of the various filtering shortcut methods."""
|
|
61
61
|
collection = ee.Collection(ee.Function(), {})
|
|
62
62
|
geom = {'type': 'Polygon', 'coordinates': [[[1, 2], [3, 4]]]}
|
|
@@ -75,7 +75,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
75
75
|
collection.filter(ee.Filter.eq('foo', 13)),
|
|
76
76
|
collection.filterMetadata('foo', 'equals', 13))
|
|
77
77
|
|
|
78
|
-
def
|
|
78
|
+
def test_mapping(self):
|
|
79
79
|
"""Verifies the behavior of the map() method."""
|
|
80
80
|
collection = ee.ImageCollection('foo')
|
|
81
81
|
algorithm = lambda img: img.select('bar')
|
|
@@ -96,7 +96,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
96
96
|
self.assertEqual(expected_function.serialize(),
|
|
97
97
|
mapped.args['baseAlgorithm'].serialize())
|
|
98
98
|
|
|
99
|
-
def
|
|
99
|
+
def test_nested_mapping(self):
|
|
100
100
|
"""Verifies that nested map() calls produce distinct variables."""
|
|
101
101
|
collection = ee.FeatureCollection('foo')
|
|
102
102
|
result = collection.map(lambda x: collection.map(lambda y: [x, y]))
|
|
@@ -115,7 +115,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
115
115
|
self.assertEqual('_MAPPING_VAR_0_0',
|
|
116
116
|
inner_result.args['baseAlgorithm']._body[1].varName)
|
|
117
117
|
|
|
118
|
-
def
|
|
118
|
+
def test_iteration(self):
|
|
119
119
|
"""Verifies the behavior of the iterate() method."""
|
|
120
120
|
collection = ee.ImageCollection('foo')
|
|
121
121
|
first = ee.Image(0)
|
|
@@ -140,7 +140,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
140
140
|
self.assertEqual(expected_function.serialize(),
|
|
141
141
|
result.args['function'].serialize())
|
|
142
142
|
|
|
143
|
-
def
|
|
143
|
+
def test_nested_functions(self):
|
|
144
144
|
"""Verifies that nested function calls produce distinct variables."""
|
|
145
145
|
fc = ee.FeatureCollection('fc')
|
|
146
146
|
def f0(feat):
|
|
@@ -159,7 +159,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
159
159
|
'0_0, 1_0, 1_1, 2_0, 2_1, 3_0, 3_1, 4_0',
|
|
160
160
|
', '.join(sorted(set(mapped_vars))))
|
|
161
161
|
|
|
162
|
-
def
|
|
162
|
+
def test_unbound_arguments(self):
|
|
163
163
|
fc = ee.FeatureCollection('fc')
|
|
164
164
|
with self.assertRaisesRegex(
|
|
165
165
|
Exception, 'User-defined methods must return a value'):
|
|
@@ -172,11 +172,11 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
172
172
|
):
|
|
173
173
|
fc.map(lambda x: x.serialize())
|
|
174
174
|
|
|
175
|
-
def
|
|
175
|
+
def test_init_opt_var_name(self):
|
|
176
176
|
result = ee.Collection(func=None, args=None, opt_varName='test').serialize()
|
|
177
177
|
self.assertIn('"argumentReference": "test"', result)
|
|
178
178
|
|
|
179
|
-
def
|
|
179
|
+
def test_filter_date_opt_params(self):
|
|
180
180
|
result = (
|
|
181
181
|
ee.Collection(func=None, args=None, varName='test')
|
|
182
182
|
.filterDate(0, opt_end=42)
|
|
@@ -184,7 +184,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
184
184
|
)
|
|
185
185
|
self.assertIn('"end": {"constantValue": 42}', result)
|
|
186
186
|
|
|
187
|
-
def
|
|
187
|
+
def test_limit_opt_params(self):
|
|
188
188
|
result = (
|
|
189
189
|
ee.Collection(func=None, args=None, varName='test')
|
|
190
190
|
.limit(0, opt_property='abc', opt_ascending=True)
|
|
@@ -193,7 +193,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
193
193
|
self.assertIn('"key": {"constantValue": "abc"}', result)
|
|
194
194
|
self.assertIn('"ascending": {"constantValue": true}', result)
|
|
195
195
|
|
|
196
|
-
def
|
|
196
|
+
def test_sort_opt_params(self):
|
|
197
197
|
result = (
|
|
198
198
|
ee.Collection(func=None, args=None, varName='test')
|
|
199
199
|
.sort('abc', opt_ascending=True)
|
|
@@ -201,7 +201,7 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
201
201
|
)
|
|
202
202
|
self.assertIn('"ascending": {"constantValue": true}', result)
|
|
203
203
|
|
|
204
|
-
def
|
|
204
|
+
def test_map_opt_params(self):
|
|
205
205
|
a_func = lambda x: ee.Image(0)
|
|
206
206
|
result = (
|
|
207
207
|
ee.Collection(func=None, args=None, varName='test')
|