mirror of
https://github.com/google/earthengine-api.git
synced 2025-12-08 19:26:12 +00:00
58 lines
1.5 KiB
Python
58 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Tests for the ee.Model module."""
|
|
|
|
import json
|
|
|
|
import ee
|
|
from ee import apitestcase
|
|
import unittest
|
|
|
|
MODEL = 'Model'
|
|
|
|
|
|
class ModelTest(apitestcase.ApiTestCase):
|
|
|
|
def test_serialize(self):
|
|
model = ee.Model.fromAiPlatformPredictor('some-project', 'some-model')
|
|
result = json.loads(model.serialize())
|
|
expect = {
|
|
'result': '0',
|
|
'values': {
|
|
'0': {
|
|
'functionInvocationValue': {
|
|
'functionName': 'Model.fromAiPlatformPredictor',
|
|
'arguments': {
|
|
'projectId': {'constantValue': 'some-model'},
|
|
'projectName': {'constantValue': 'some-project'},
|
|
},
|
|
}
|
|
}
|
|
},
|
|
}
|
|
self.assertEqual(expect, result)
|
|
|
|
def test_cast(self):
|
|
model = ee.Model(
|
|
ee.Model.fromAiPlatformPredictor('some-project', 'some-model')
|
|
)
|
|
result = json.loads(model.serialize())
|
|
expect = {
|
|
'result': '0',
|
|
'values': {
|
|
'0': {
|
|
'functionInvocationValue': {
|
|
'functionName': 'Model.fromAiPlatformPredictor',
|
|
'arguments': {
|
|
'projectId': {'constantValue': 'some-model'},
|
|
'projectName': {'constantValue': 'some-project'},
|
|
},
|
|
}
|
|
}
|
|
},
|
|
}
|
|
self.assertEqual(expect, result)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|