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/data_test.py
CHANGED
|
@@ -12,6 +12,7 @@ import requests
|
|
|
12
12
|
import unittest
|
|
13
13
|
import ee
|
|
14
14
|
from ee import _cloud_api_utils
|
|
15
|
+
from ee import _state
|
|
15
16
|
from ee import apitestcase
|
|
16
17
|
from ee import featurecollection
|
|
17
18
|
from ee import image
|
|
@@ -52,41 +53,46 @@ class DataTest(unittest.TestCase):
|
|
|
52
53
|
ee.data.reset()
|
|
53
54
|
mock.patch.stopall()
|
|
54
55
|
|
|
55
|
-
def
|
|
56
|
+
def test_is_initialized(self):
|
|
56
57
|
self.assertFalse(ee.data.is_initialized())
|
|
57
58
|
with apitestcase.UsingCloudApi():
|
|
58
59
|
self.assertTrue(ee.data.is_initialized())
|
|
59
60
|
|
|
60
61
|
@mock.patch.object(ee.data, '_install_cloud_api_resource', return_value=None)
|
|
61
|
-
def
|
|
62
|
+
def test_initialize(self, mock_install_cloud_api_resource):
|
|
62
63
|
ee.data.initialize()
|
|
63
64
|
|
|
64
65
|
self.assertTrue(ee.data.is_initialized())
|
|
65
66
|
mock_install_cloud_api_resource.assert_called_once()
|
|
66
67
|
|
|
67
68
|
@mock.patch.object(ee.data, '_install_cloud_api_resource', return_value=None)
|
|
68
|
-
def
|
|
69
|
+
def test_initialize_with_project(self, unused_mock_install_cloud_api_resource):
|
|
69
70
|
ee.data.initialize(project='my-project')
|
|
70
71
|
|
|
71
72
|
self.assertTrue(ee.data.is_initialized())
|
|
72
|
-
self.assertEqual(
|
|
73
|
+
self.assertEqual(
|
|
74
|
+
_state.get_state().cloud_api_user_project, 'my-project'
|
|
75
|
+
)
|
|
73
76
|
|
|
74
77
|
@mock.patch.object(ee.data, '_install_cloud_api_resource', return_value=None)
|
|
75
|
-
def
|
|
78
|
+
def test_initialize_with_no_project(
|
|
79
|
+
self, unused_mock_install_cloud_api_resource
|
|
80
|
+
):
|
|
76
81
|
ee.data.initialize()
|
|
77
82
|
|
|
78
83
|
self.assertTrue(ee.data.is_initialized())
|
|
79
|
-
self.assertEqual(
|
|
84
|
+
self.assertEqual(
|
|
85
|
+
_state.get_state().cloud_api_user_project, 'earthengine-legacy'
|
|
86
|
+
)
|
|
80
87
|
|
|
81
|
-
def
|
|
88
|
+
def test_set_max_retries_bad_values(self):
|
|
82
89
|
with self.assertRaises(ValueError):
|
|
83
90
|
ee.data.setMaxRetries(-1)
|
|
84
91
|
with self.assertRaises(ValueError):
|
|
85
92
|
ee.data.setMaxRetries(100)
|
|
86
93
|
|
|
87
|
-
def
|
|
94
|
+
def test_set_max_retries(self):
|
|
88
95
|
mock_result = {'result': 5}
|
|
89
|
-
original_max_retries = ee.data._max_retries
|
|
90
96
|
ee.data.setMaxRetries(3)
|
|
91
97
|
cloud_api_resource = mock.MagicMock()
|
|
92
98
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
@@ -101,9 +107,8 @@ class DataTest(unittest.TestCase):
|
|
|
101
107
|
.compute()
|
|
102
108
|
.execute.call_args.kwargs['num_retries'],
|
|
103
109
|
)
|
|
104
|
-
ee.data._max_retries = original_max_retries
|
|
105
110
|
|
|
106
|
-
def
|
|
111
|
+
def test_list_operations(self):
|
|
107
112
|
mock_http = mock.MagicMock(httplib2.Http)
|
|
108
113
|
# Return in three groups.
|
|
109
114
|
mock_http.request.side_effect = [
|
|
@@ -123,14 +128,14 @@ class DataTest(unittest.TestCase):
|
|
|
123
128
|
'name': 'name3'
|
|
124
129
|
}], ee.data.listOperations())
|
|
125
130
|
|
|
126
|
-
def
|
|
131
|
+
def test_list_operations_empty_list(self):
|
|
127
132
|
# Empty lists don't appear at all in the result.
|
|
128
133
|
mock_http = mock.MagicMock(httplib2.Http)
|
|
129
134
|
mock_http.request.return_value = (httplib2.Response({'status': 200}), b'{}')
|
|
130
135
|
with apitestcase.UsingCloudApi(mock_http=mock_http):
|
|
131
136
|
self.assertEqual([], ee.data.listOperations())
|
|
132
137
|
|
|
133
|
-
def
|
|
138
|
+
def test_get_operation(self):
|
|
134
139
|
cloud_api_resource = mock.MagicMock()
|
|
135
140
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
136
141
|
name = 'projects/test-project/operations/foo'
|
|
@@ -143,7 +148,7 @@ class DataTest(unittest.TestCase):
|
|
|
143
148
|
name=name
|
|
144
149
|
)
|
|
145
150
|
|
|
146
|
-
def
|
|
151
|
+
def test_get_task_status(self):
|
|
147
152
|
cloud_api_resource = mock.MagicMock()
|
|
148
153
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
149
154
|
cloud_api_resource.projects().operations().get.return_value.execute.return_value = {
|
|
@@ -164,7 +169,7 @@ class DataTest(unittest.TestCase):
|
|
|
164
169
|
}],
|
|
165
170
|
)
|
|
166
171
|
|
|
167
|
-
def
|
|
172
|
+
def test_get_task_status_with_not_found(self):
|
|
168
173
|
cloud_api_resource = mock.MagicMock()
|
|
169
174
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
170
175
|
cloud_api_resource.projects().operations().get.return_value.execute.side_effect = [
|
|
@@ -216,7 +221,7 @@ class DataTest(unittest.TestCase):
|
|
|
216
221
|
],
|
|
217
222
|
)
|
|
218
223
|
|
|
219
|
-
def
|
|
224
|
+
def test_cancel_operation(self):
|
|
220
225
|
cloud_api_resource = mock.MagicMock()
|
|
221
226
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
222
227
|
cancel_mock = cloud_api_resource.projects().operations().cancel
|
|
@@ -226,7 +231,7 @@ class DataTest(unittest.TestCase):
|
|
|
226
231
|
name='projects/test-project/operations/foo', body={}
|
|
227
232
|
)
|
|
228
233
|
|
|
229
|
-
def
|
|
234
|
+
def test_cancel_task(self):
|
|
230
235
|
cloud_api_resource = mock.MagicMock()
|
|
231
236
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
232
237
|
cancel_mock = cloud_api_resource.projects().operations().cancel
|
|
@@ -236,7 +241,7 @@ class DataTest(unittest.TestCase):
|
|
|
236
241
|
name='projects/earthengine-legacy/operations/foo', body={}
|
|
237
242
|
)
|
|
238
243
|
|
|
239
|
-
def
|
|
244
|
+
def test_create_asset(self):
|
|
240
245
|
cloud_api_resource = mock.MagicMock()
|
|
241
246
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
242
247
|
mock_result = {
|
|
@@ -257,7 +262,7 @@ class DataTest(unittest.TestCase):
|
|
|
257
262
|
asset = mock_create_asset.call_args.kwargs['body']
|
|
258
263
|
self.assertEqual(asset, {'type': 'FOLDER'})
|
|
259
264
|
|
|
260
|
-
def
|
|
265
|
+
def test_create_asset_with_v1alpha_params(self):
|
|
261
266
|
cloud_api_resource = mock.MagicMock()
|
|
262
267
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
263
268
|
mock_result = {
|
|
@@ -314,7 +319,7 @@ class DataTest(unittest.TestCase):
|
|
|
314
319
|
{'uris': ['gs://my-bucket/path']},
|
|
315
320
|
)
|
|
316
321
|
|
|
317
|
-
def
|
|
322
|
+
def test_create_folder(self):
|
|
318
323
|
cloud_api_resource = mock.MagicMock()
|
|
319
324
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
320
325
|
mock_result = {
|
|
@@ -335,7 +340,7 @@ class DataTest(unittest.TestCase):
|
|
|
335
340
|
asset = mock_create_asset.call_args.kwargs['body']
|
|
336
341
|
self.assertEqual(asset, {'type': 'FOLDER'})
|
|
337
342
|
|
|
338
|
-
def
|
|
343
|
+
def test_create_assets(self):
|
|
339
344
|
cloud_api_resource = mock.MagicMock()
|
|
340
345
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
341
346
|
asset_name = 'projects/some-project/assets/some-asset'
|
|
@@ -351,14 +356,14 @@ class DataTest(unittest.TestCase):
|
|
|
351
356
|
prettyPrint=False,
|
|
352
357
|
)
|
|
353
358
|
|
|
354
|
-
def
|
|
359
|
+
def test_create_assets_empty(self):
|
|
355
360
|
cloud_api_resource = mock.MagicMock()
|
|
356
361
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
357
362
|
ee.data.create_assets([], 'FOLDER', False)
|
|
358
363
|
mock_create_asset = cloud_api_resource.projects().assets().create
|
|
359
364
|
mock_create_asset.assert_not_called()
|
|
360
365
|
|
|
361
|
-
def
|
|
366
|
+
def test_create_assets_no_op_if_asset_exists(self):
|
|
362
367
|
cloud_api_resource = mock.MagicMock()
|
|
363
368
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
364
369
|
asset_name = 'projects/some-project/assets/some-asset'
|
|
@@ -369,7 +374,7 @@ class DataTest(unittest.TestCase):
|
|
|
369
374
|
mock_create_asset = cloud_api_resource.projects().assets().create
|
|
370
375
|
mock_create_asset.assert_not_called()
|
|
371
376
|
|
|
372
|
-
def
|
|
377
|
+
def test_create_assets_with_parents(self):
|
|
373
378
|
cloud_api_resource = mock.MagicMock()
|
|
374
379
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
375
380
|
asset_name = 'projects/some-project/assets/foo/bar'
|
|
@@ -395,7 +400,7 @@ class DataTest(unittest.TestCase):
|
|
|
395
400
|
mock.call().execute(num_retries=5),
|
|
396
401
|
])
|
|
397
402
|
|
|
398
|
-
def
|
|
403
|
+
def test_start_ingestion(self):
|
|
399
404
|
cloud_api_resource = mock.MagicMock()
|
|
400
405
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
401
406
|
mock_result = {'name': 'operations/ingestion', 'done': False}
|
|
@@ -425,7 +430,7 @@ class DataTest(unittest.TestCase):
|
|
|
425
430
|
)
|
|
426
431
|
self.assertTrue(import_args['overwrite'])
|
|
427
432
|
|
|
428
|
-
def
|
|
433
|
+
def test_set_asset_properties(self):
|
|
429
434
|
mock_http = mock.MagicMock(httplib2.Http)
|
|
430
435
|
with apitestcase.UsingCloudApi(mock_http=mock_http), mock.patch.object(
|
|
431
436
|
ee.data, 'updateAsset', autospec=True) as mock_update_asset:
|
|
@@ -446,7 +451,7 @@ class DataTest(unittest.TestCase):
|
|
|
446
451
|
{'properties.\"mYPropErTy\"',
|
|
447
452
|
'properties.\"system:time_start\"'})
|
|
448
453
|
|
|
449
|
-
def
|
|
454
|
+
def test_list_assets(self):
|
|
450
455
|
cloud_api_resource = mock.MagicMock()
|
|
451
456
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
452
457
|
mock_result = {'assets': [{'path': 'id1', 'type': 'type1'}]}
|
|
@@ -458,7 +463,7 @@ class DataTest(unittest.TestCase):
|
|
|
458
463
|
).execute.assert_called_once()
|
|
459
464
|
self.assertEqual(mock_result, actual_result)
|
|
460
465
|
|
|
461
|
-
def
|
|
466
|
+
def test_list_assets_with_page_size(self):
|
|
462
467
|
mock_http = mock.MagicMock(httplib2.Http)
|
|
463
468
|
ok_resp = httplib2.Response({'status': 200})
|
|
464
469
|
page = (
|
|
@@ -475,7 +480,7 @@ class DataTest(unittest.TestCase):
|
|
|
475
480
|
}
|
|
476
481
|
self.assertEqual(expected_result, actual_result)
|
|
477
482
|
|
|
478
|
-
def
|
|
483
|
+
def test_list_assets_multiple_pages(self):
|
|
479
484
|
mock_http = mock.MagicMock(httplib2.Http)
|
|
480
485
|
ok_resp = httplib2.Response({'status': 200})
|
|
481
486
|
page1 = (
|
|
@@ -501,7 +506,7 @@ class DataTest(unittest.TestCase):
|
|
|
501
506
|
}
|
|
502
507
|
self.assertEqual(expected_result, actual_result)
|
|
503
508
|
|
|
504
|
-
def
|
|
509
|
+
def test_list_images(self):
|
|
505
510
|
cloud_api_resource = mock.MagicMock()
|
|
506
511
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
507
512
|
mock_result = {'assets': [{'path': 'id1', 'type': 'type1'}]}
|
|
@@ -516,7 +521,7 @@ class DataTest(unittest.TestCase):
|
|
|
516
521
|
'type': 'type1'
|
|
517
522
|
}]}, actual_result)
|
|
518
523
|
|
|
519
|
-
def
|
|
524
|
+
def test_list_images_with_page_size(self):
|
|
520
525
|
mock_http = mock.MagicMock(httplib2.Http)
|
|
521
526
|
ok_resp = httplib2.Response({'status': 200})
|
|
522
527
|
page = (
|
|
@@ -533,7 +538,7 @@ class DataTest(unittest.TestCase):
|
|
|
533
538
|
}
|
|
534
539
|
self.assertEqual(expected_result, actual_result)
|
|
535
540
|
|
|
536
|
-
def
|
|
541
|
+
def test_list_images_multiple_pages(self):
|
|
537
542
|
mock_http = mock.MagicMock(httplib2.Http)
|
|
538
543
|
ok_resp = httplib2.Response({'status': 200})
|
|
539
544
|
page1 = (
|
|
@@ -559,7 +564,7 @@ class DataTest(unittest.TestCase):
|
|
|
559
564
|
}
|
|
560
565
|
self.assertEqual(expected_result, actual_result)
|
|
561
566
|
|
|
562
|
-
def
|
|
567
|
+
def test_list_buckets(self):
|
|
563
568
|
cloud_api_resource = mock.MagicMock()
|
|
564
569
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
565
570
|
mock_result = {'assets': [{'name': 'id1', 'type': 'FOLDER'}]}
|
|
@@ -569,7 +574,7 @@ class DataTest(unittest.TestCase):
|
|
|
569
574
|
cloud_api_resource.projects().listAssets().execute.assert_called_once()
|
|
570
575
|
self.assertEqual(mock_result, actual_result)
|
|
571
576
|
|
|
572
|
-
def
|
|
577
|
+
def test_simple_get_list_via_cloud_api(self):
|
|
573
578
|
cloud_api_resource = mock.MagicMock()
|
|
574
579
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
575
580
|
mock_result = {'assets': [{'name': 'id1', 'type': 'IMAGE_COLLECTION'}]}
|
|
@@ -586,7 +591,7 @@ class DataTest(unittest.TestCase):
|
|
|
586
591
|
**expected_params)
|
|
587
592
|
self.assertEqual(expected_result, actual_result)
|
|
588
593
|
|
|
589
|
-
def
|
|
594
|
+
def test_get_list_asset_root_via_cloud_api(self):
|
|
590
595
|
cloud_api_resource = mock.MagicMock()
|
|
591
596
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
592
597
|
mock_result = {'assets': [{'name': 'id1', 'type': 'IMAGE_COLLECTION'}]}
|
|
@@ -606,7 +611,7 @@ class DataTest(unittest.TestCase):
|
|
|
606
611
|
**expected_params)
|
|
607
612
|
self.assertEqual(expected_result, actual_result)
|
|
608
613
|
|
|
609
|
-
def
|
|
614
|
+
def test_get_list_asset_root_via_cloud_api_no_slash(self):
|
|
610
615
|
cloud_api_resource = mock.MagicMock()
|
|
611
616
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
612
617
|
mock_result = {'assets': [{'name': 'id1', 'type': 'IMAGE_COLLECTION'}]}
|
|
@@ -626,7 +631,7 @@ class DataTest(unittest.TestCase):
|
|
|
626
631
|
**expected_params)
|
|
627
632
|
self.assertEqual(expected_result, actual_result)
|
|
628
633
|
|
|
629
|
-
def
|
|
634
|
+
def test_complex_get_list_via_cloud_api(self):
|
|
630
635
|
cloud_api_resource = mock.MagicMock()
|
|
631
636
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
632
637
|
mock_result = {
|
|
@@ -655,7 +660,7 @@ class DataTest(unittest.TestCase):
|
|
|
655
660
|
**expected_params)
|
|
656
661
|
self.assertEqual(expected_result, actual_result)
|
|
657
662
|
|
|
658
|
-
def
|
|
663
|
+
def test_get_map_id(self):
|
|
659
664
|
cloud_api_resource = mock.MagicMock()
|
|
660
665
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
661
666
|
mock_result = {
|
|
@@ -672,7 +677,7 @@ class DataTest(unittest.TestCase):
|
|
|
672
677
|
self.assertEqual('', actual_result['token'])
|
|
673
678
|
self.assertIsInstance(actual_result['tile_fetcher'], ee.data.TileFetcher)
|
|
674
679
|
|
|
675
|
-
def
|
|
680
|
+
def test_get_map_id_with_workload_tag(self):
|
|
676
681
|
with ee.data.workloadTagContext('mapid-tag'):
|
|
677
682
|
cloud_api_resource = mock.MagicMock()
|
|
678
683
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
@@ -689,7 +694,7 @@ class DataTest(unittest.TestCase):
|
|
|
689
694
|
cloud_api_resource.projects().maps().create.call_args_list[1]
|
|
690
695
|
.kwargs['workloadTag'])
|
|
691
696
|
|
|
692
|
-
def
|
|
697
|
+
def test_get_download_id(self):
|
|
693
698
|
cloud_api_resource = mock.MagicMock()
|
|
694
699
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
695
700
|
mock_result = {'name': 'projects/earthengine-legacy/thumbnails/DOCID'}
|
|
@@ -707,7 +712,7 @@ class DataTest(unittest.TestCase):
|
|
|
707
712
|
'token': ''
|
|
708
713
|
}, actual_result)
|
|
709
714
|
|
|
710
|
-
def
|
|
715
|
+
def test_get_download_id_with_workload_tag(self):
|
|
711
716
|
with ee.data.workloadTagContext('downloadid-tag'):
|
|
712
717
|
cloud_api_resource = mock.MagicMock()
|
|
713
718
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
@@ -723,7 +728,7 @@ class DataTest(unittest.TestCase):
|
|
|
723
728
|
cloud_api_resource.projects().thumbnails().create.call_args
|
|
724
729
|
.kwargs['workloadTag'])
|
|
725
730
|
|
|
726
|
-
def
|
|
731
|
+
def test_get_download_id_with_band_list(self):
|
|
727
732
|
cloud_api_resource = mock.MagicMock()
|
|
728
733
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
729
734
|
mock_result = {'name': 'projects/earthengine-legacy/thumbnails/DOCID'}
|
|
@@ -742,14 +747,14 @@ class DataTest(unittest.TestCase):
|
|
|
742
747
|
'token': ''
|
|
743
748
|
}, actual_result)
|
|
744
749
|
|
|
745
|
-
def
|
|
750
|
+
def test_get_download_id_with_image_id(self):
|
|
746
751
|
cloud_api_resource = mock.MagicMock()
|
|
747
752
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
748
753
|
with self.assertRaisesRegex(ee.ee_exception.EEException,
|
|
749
754
|
'^Image ID string is not supported.'):
|
|
750
755
|
ee.data.getDownloadId({'id': 'my-image', 'name': 'dummy'})
|
|
751
756
|
|
|
752
|
-
def
|
|
757
|
+
def test_get_download_id_with_serialized_image(self):
|
|
753
758
|
cloud_api_resource = mock.MagicMock()
|
|
754
759
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
755
760
|
with self.assertRaisesRegex(ee.ee_exception.EEException,
|
|
@@ -759,7 +764,7 @@ class DataTest(unittest.TestCase):
|
|
|
759
764
|
'name': 'dummy'
|
|
760
765
|
})
|
|
761
766
|
|
|
762
|
-
def
|
|
767
|
+
def test_get_thumb_id(self):
|
|
763
768
|
cloud_api_resource = mock.MagicMock()
|
|
764
769
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
765
770
|
mock_result = {'name': 'projects/earthengine-legacy/thumbnails/DOCID'}
|
|
@@ -777,7 +782,7 @@ class DataTest(unittest.TestCase):
|
|
|
777
782
|
'token': ''
|
|
778
783
|
}, actual_result)
|
|
779
784
|
|
|
780
|
-
def
|
|
785
|
+
def test_get_thumb_id_with_workload_tag(self):
|
|
781
786
|
with ee.data.workloadTagContext('thumbid-tag'):
|
|
782
787
|
cloud_api_resource = mock.MagicMock()
|
|
783
788
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
@@ -790,7 +795,7 @@ class DataTest(unittest.TestCase):
|
|
|
790
795
|
cloud_api_resource.projects().thumbnails().create.call_args
|
|
791
796
|
.kwargs['workloadTag'])
|
|
792
797
|
|
|
793
|
-
def
|
|
798
|
+
def test_get_table_download_id(self):
|
|
794
799
|
cloud_api_resource = mock.MagicMock()
|
|
795
800
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
796
801
|
mock_result = {'name': 'projects/earthengine-legacy/table/DOCID'}
|
|
@@ -808,7 +813,7 @@ class DataTest(unittest.TestCase):
|
|
|
808
813
|
'token': ''
|
|
809
814
|
}, actual_result)
|
|
810
815
|
|
|
811
|
-
def
|
|
816
|
+
def test_get_table_download_id_with_workload_tag(self):
|
|
812
817
|
with ee.data.workloadTagContext('tableid-tag'):
|
|
813
818
|
cloud_api_resource = mock.MagicMock()
|
|
814
819
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
@@ -824,7 +829,7 @@ class DataTest(unittest.TestCase):
|
|
|
824
829
|
cloud_api_resource.projects().tables().create.call_args
|
|
825
830
|
.kwargs['workloadTag'])
|
|
826
831
|
|
|
827
|
-
def
|
|
832
|
+
def test_cloud_profiling_enabled(self):
|
|
828
833
|
seen = []
|
|
829
834
|
|
|
830
835
|
def ProfileHook(profile_id):
|
|
@@ -835,11 +840,11 @@ class DataTest(unittest.TestCase):
|
|
|
835
840
|
ee.data.listImages({'parent': 'projects/earthengine-public/assets/q'})
|
|
836
841
|
self.assertEqual(['someProfileId'], seen)
|
|
837
842
|
|
|
838
|
-
def
|
|
843
|
+
def test_cloud_profiling_disabled(self):
|
|
839
844
|
with apitestcase.UsingCloudApi(), DoCloudProfileStubHttp(self, False):
|
|
840
845
|
ee.data.listImages({'parent': 'projects/earthengine-public/assets/q'})
|
|
841
846
|
|
|
842
|
-
def
|
|
847
|
+
def test_cloud_error_translation(self):
|
|
843
848
|
mock_http = mock.MagicMock(httplib2.Http)
|
|
844
849
|
mock_http.request.return_value = (httplib2.Response({'status': 400}),
|
|
845
850
|
b'{"error": {"message": "errorly"} }')
|
|
@@ -847,7 +852,7 @@ class DataTest(unittest.TestCase):
|
|
|
847
852
|
with self.assertRaisesRegex(ee.ee_exception.EEException, '^errorly$'):
|
|
848
853
|
ee.data.listImages({'parent': 'projects/earthengine-public/assets/q'})
|
|
849
854
|
|
|
850
|
-
def
|
|
855
|
+
def test_list_features(self):
|
|
851
856
|
cloud_api_resource = mock.MagicMock()
|
|
852
857
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
853
858
|
mock_result = {
|
|
@@ -874,9 +879,9 @@ class DataTest(unittest.TestCase):
|
|
|
874
879
|
).execute.assert_called_once()
|
|
875
880
|
self.assertEqual(mock_result, actual_result)
|
|
876
881
|
|
|
877
|
-
|
|
878
|
-
def testGetFeatureViewTilesKey(self):
|
|
882
|
+
def test_get_feature_view_tiles_key(self):
|
|
879
883
|
cloud_api_resource = mock.MagicMock()
|
|
884
|
+
_state.get_state().tile_base_url = 'base_url'
|
|
880
885
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
881
886
|
mock_name = 'projects/projectfoo/featureView/tiles-key-foo'
|
|
882
887
|
mock_result = {'name': mock_name}
|
|
@@ -897,7 +902,7 @@ class DataTest(unittest.TestCase):
|
|
|
897
902
|
f'base_url/{_cloud_api_utils.VERSION}/{mock_name}/tiles/7/5/6',
|
|
898
903
|
actual_result['formatTileUrl'](5, 6, 7))
|
|
899
904
|
|
|
900
|
-
def
|
|
905
|
+
def test_get_project_config(self) -> None:
|
|
901
906
|
cloud_api_resource = mock.MagicMock()
|
|
902
907
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
903
908
|
mock_result = {'fake-project-config-value': 1}
|
|
@@ -908,7 +913,7 @@ class DataTest(unittest.TestCase):
|
|
|
908
913
|
cloud_api_resource.projects().getConfig().execute.assert_called_once()
|
|
909
914
|
self.assertEqual(mock_result, actual_result)
|
|
910
915
|
|
|
911
|
-
def
|
|
916
|
+
def test_update_project_config(self) -> None:
|
|
912
917
|
cloud_api_resource = mock.MagicMock()
|
|
913
918
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
914
919
|
mock_result = {'fake-project-config-value': 1}
|
|
@@ -921,7 +926,7 @@ class DataTest(unittest.TestCase):
|
|
|
921
926
|
cloud_api_resource.projects().updateConfig().execute.assert_called_once()
|
|
922
927
|
self.assertEqual(mock_result, actual_result)
|
|
923
928
|
|
|
924
|
-
def
|
|
929
|
+
def test_workload_tag(self):
|
|
925
930
|
self.assertEqual('', ee.data.getWorkloadTag())
|
|
926
931
|
ee.data.setDefaultWorkloadTag(None)
|
|
927
932
|
self.assertEqual('', ee.data.getWorkloadTag())
|
|
@@ -979,13 +984,13 @@ class DataTest(unittest.TestCase):
|
|
|
979
984
|
ee.data.resetWorkloadTag(True)
|
|
980
985
|
self.assertEqual('', ee.data.getWorkloadTag())
|
|
981
986
|
|
|
982
|
-
def
|
|
987
|
+
def test_reset_workload_tag_opt_params(self):
|
|
983
988
|
ee.data.setDefaultWorkloadTag('reset-me')
|
|
984
989
|
self.assertEqual('reset-me', ee.data.getWorkloadTag())
|
|
985
990
|
ee.data.resetWorkloadTag(opt_resetDefault=True)
|
|
986
991
|
self.assertEqual('', ee.data.getWorkloadTag())
|
|
987
992
|
|
|
988
|
-
def
|
|
993
|
+
def test_get_asset_root_quota_v1alpha(self):
|
|
989
994
|
cloud_api_resource = mock.MagicMock()
|
|
990
995
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
991
996
|
fake_asset = {
|
|
@@ -1009,7 +1014,7 @@ class DataTest(unittest.TestCase):
|
|
|
1009
1014
|
}
|
|
1010
1015
|
self.assertEqual(expected, quota)
|
|
1011
1016
|
|
|
1012
|
-
def
|
|
1017
|
+
def test_get_asset_root_quota(self):
|
|
1013
1018
|
cloud_api_resource = mock.MagicMock()
|
|
1014
1019
|
with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
|
|
1015
1020
|
fake_asset = {
|
ee/tests/dictionary_test.py
CHANGED
|
@@ -20,7 +20,7 @@ def make_expression_graph(
|
|
|
20
20
|
|
|
21
21
|
class DictionaryTest(apitestcase.ApiTestCase):
|
|
22
22
|
|
|
23
|
-
def
|
|
23
|
+
def test_dictionary(self):
|
|
24
24
|
"""Verifies basic behavior of ee.Dictionary."""
|
|
25
25
|
src = {'a': 1, 'b': 2, 'c': 'three'}
|
|
26
26
|
dictionary = ee.Dictionary(src)
|
|
@@ -46,7 +46,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
|
|
|
46
46
|
for d in cons:
|
|
47
47
|
self.assertIsInstance(d, ee.ComputedObject)
|
|
48
48
|
|
|
49
|
-
def
|
|
49
|
+
def test_internals(self):
|
|
50
50
|
"""Test eq(), ne() and hash()."""
|
|
51
51
|
a = ee.Dictionary({'one': 1})
|
|
52
52
|
b = ee.Dictionary({'two': 2})
|
|
@@ -93,7 +93,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
|
|
|
93
93
|
result = json.loads(expression.serialize())
|
|
94
94
|
self.assertEqual(expect, result)
|
|
95
95
|
|
|
96
|
-
def
|
|
96
|
+
def test_from_lists(self):
|
|
97
97
|
expect = make_expression_graph({
|
|
98
98
|
'arguments': {
|
|
99
99
|
'keys': {'constantValue': ['a']},
|
|
@@ -126,7 +126,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
|
|
|
126
126
|
result = json.loads(expression.serialize())
|
|
127
127
|
self.assertEqual(expect, result)
|
|
128
128
|
|
|
129
|
-
def
|
|
129
|
+
def test_get_array(self):
|
|
130
130
|
expect = make_expression_graph({
|
|
131
131
|
'arguments': {
|
|
132
132
|
'dictionary': {'constantValue': {'a': 1}},
|
|
@@ -142,7 +142,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
|
|
|
142
142
|
result = json.loads(expression.serialize())
|
|
143
143
|
self.assertEqual(expect, result)
|
|
144
144
|
|
|
145
|
-
def
|
|
145
|
+
def test_get_geometry(self):
|
|
146
146
|
expect = make_expression_graph({
|
|
147
147
|
'arguments': {
|
|
148
148
|
'dictionary': {'constantValue': {'a': 1}},
|
|
@@ -158,7 +158,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
|
|
|
158
158
|
result = json.loads(expression.serialize())
|
|
159
159
|
self.assertEqual(expect, result)
|
|
160
160
|
|
|
161
|
-
def
|
|
161
|
+
def test_get_number(self):
|
|
162
162
|
expect = make_expression_graph({
|
|
163
163
|
'arguments': {
|
|
164
164
|
'dictionary': {'constantValue': {'a': 1}},
|
|
@@ -174,7 +174,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
|
|
|
174
174
|
result = json.loads(expression.serialize())
|
|
175
175
|
self.assertEqual(expect, result)
|
|
176
176
|
|
|
177
|
-
def
|
|
177
|
+
def test_get_string(self):
|
|
178
178
|
expect = make_expression_graph({
|
|
179
179
|
'arguments': {
|
|
180
180
|
'dictionary': {'constantValue': {'a': 1}},
|
|
@@ -292,7 +292,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
|
|
|
292
292
|
result = json.loads(expression.serialize())
|
|
293
293
|
self.assertEqual(expect, result)
|
|
294
294
|
|
|
295
|
-
def
|
|
295
|
+
def test_to_array(self):
|
|
296
296
|
expect = make_expression_graph({
|
|
297
297
|
'arguments': {
|
|
298
298
|
'dictionary': {'constantValue': {'a': 1}},
|
|
@@ -325,7 +325,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
|
|
|
325
325
|
result = json.loads(expression.serialize())
|
|
326
326
|
self.assertEqual(expect, result)
|
|
327
327
|
|
|
328
|
-
def
|
|
328
|
+
def test_to_image(self):
|
|
329
329
|
expect = make_expression_graph({
|
|
330
330
|
'arguments': {
|
|
331
331
|
'dictionary': {'constantValue': {'a': 1}},
|