mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
generator lib: Initial tests
Move existing tests into a new __tests__ module under generator/lib. Also define a new test for `util.new_context`, to prevent regressions as changes are made.
This commit is contained in:
1369
src/generator/lib/__tests__/context_test.py
Normal file
1369
src/generator/lib/__tests__/context_test.py
Normal file
File diff suppressed because it is too large
Load Diff
0
src/generator/lib/__tests__/test_data/__init__.py
Normal file
0
src/generator/lib/__tests__/test_data/__init__.py
Normal file
@@ -1,3 +1,6 @@
|
||||
# Discovery document for photoslibrary, retrieved from:
|
||||
# https://photoslibrary.googleapis.com/$discovery/rest?version=v1
|
||||
DISCOVERY_DOC = r"""
|
||||
{
|
||||
"documentationLink": "https://developers.google.com/photos/",
|
||||
"id": "photoslibrary:v1",
|
||||
@@ -1332,3 +1335,4 @@
|
||||
"kind": "discovery#restDescription",
|
||||
"basePath": ""
|
||||
}
|
||||
"""
|
||||
@@ -1,20 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import importlib.resources
|
||||
import unittest
|
||||
import json
|
||||
|
||||
from generator.lib.util import to_api_version, library_name, re_find_replacements, to_rust_type, new_context
|
||||
import generator.lib.test_data as test_data
|
||||
from generator.lib.util import to_api_version, library_name, re_find_replacements, to_rust_type
|
||||
from .test_data.discovery_document import DISCOVERY_DOC
|
||||
|
||||
|
||||
TEST_JSON_FILE = "photoslibrary-api.json"
|
||||
|
||||
|
||||
def read_test_json_file():
|
||||
data = importlib.resources.read_text(test_data, TEST_JSON_FILE)
|
||||
return json.loads(data)
|
||||
|
||||
class UtilsTest(unittest.TestCase):
|
||||
|
||||
def test_to_version_ok(self):
|
||||
@@ -68,7 +60,7 @@ class UtilsTest(unittest.TestCase):
|
||||
self.assertEqual(ms[0], '{+project}')
|
||||
|
||||
def test_to_rust_type(self):
|
||||
full_api_schema = read_test_json_file()
|
||||
full_api_schema = json.loads(DISCOVERY_DOC)
|
||||
|
||||
schemas = full_api_schema['schemas']
|
||||
|
||||
Reference in New Issue
Block a user