earthengine-api/python/ee/tests/model_test.py
Google Earth Engine Authors e9cc3423fb v0.1.403
PiperOrigin-RevId: 632474175
2024-05-15 17:59:00 +00:00

58 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Tests for the ee.Model module."""
import json
import unittest
import ee
from ee import apitestcase
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()