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

Method test_unbound_methods

python/ee/tests/ee_test.py:436–477  ·  view source on GitHub ↗

Verifies unbound method attachment to ee.Algorithms.

(self)

Source from the content-addressed store, hash-verified

434 self.assertEqual('foo', ee._Promote(untyped, 'Element').varName)
435
436 def test_unbound_methods(self):
437 """Verifies unbound method attachment to ee.Algorithms."""
438
439 # Use a custom set of known functions.
440 def MockAlgorithms():
441 return {
442 'Foo': {
443 'type': 'Algorithm',
444 'args': [],
445 'description': '',
446 'returns': 'Object'
447 },
448 'Foo.bar': {
449 'type': 'Algorithm',
450 'args': [],
451 'description': '',
452 'returns': 'Object'
453 },
454 'Quux.baz': {
455 'type': 'Algorithm',
456 'args': [],
457 'description': '',
458 'returns': 'Object'
459 },
460 'last': {
461 'type': 'Algorithm',
462 'args': [],
463 'description': '',
464 'returns': 'Object'
465 }
466 }
467
468 ee.data.getAlgorithms = MockAlgorithms
469
470 ee.ApiFunction.importApi(lambda: None, 'Quux', 'Quux')
471 ee._InitializeUnboundMethods()
472
473 self.assertTrue(callable(ee.Algorithms.Foo))
474 self.assertTrue(callable(ee.Algorithms.Foo.bar))
475 self.assertNotIn('Quux', ee.Algorithms)
476 self.assertEqual(ee.call('Foo.bar'), ee.Algorithms.Foo.bar())
477 self.assertNotEqual(ee.Algorithms.Foo.bar(), ee.Algorithms.last())
478
479 def test_non_ascii_documentation(self):
480 """Verifies that non-ASCII characters in documentation work."""

Callers

nothing calls this directly

Calls 4

importApiMethod · 0.80
callMethod · 0.80
barMethod · 0.80
lastMethod · 0.80

Tested by

no test coverage detected