@darabonba/python-generator 2.0.2 → 2.0.3
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.
- package/.github/workflows/ci.yml +1 -1
- package/ChangeLog.md +12 -0
- package/lib/generator.js +195 -109
- package/lib/helper.js +21 -1
- package/package.json +1 -1
- package/tests/expected/{python3/model/tea_python_tests/client.py → annotation/tea_python_tests/models/__init__.py} +6 -3
- package/tests/expected/annotation/tea_python_tests/{models.py → models/_test.py} +1 -1
- package/tests/expected/comment/tea_python_tests/models/__init__.py +15 -0
- package/tests/expected/comment/tea_python_tests/models/_test_1.py +91 -0
- package/tests/expected/comment/tea_python_tests/models/_test_2.py +55 -0
- package/tests/expected/comment/tea_python_tests/models/_test_3.py +61 -0
- package/tests/expected/complex/tea_python_tests/client.py +6 -6
- package/tests/expected/complex/tea_python_tests/exceptions/__init__.py +13 -0
- package/tests/expected/complex/tea_python_tests/exceptions/_err_1.py +23 -0
- package/tests/expected/complex/tea_python_tests/exceptions/_err_2.py +22 -0
- package/tests/expected/complex/tea_python_tests/models/__init__.py +19 -0
- package/tests/{output/complex/tea_python_tests/models.py → expected/complex/tea_python_tests/models/_complex_request.py} +12 -141
- package/tests/expected/complex/tea_python_tests/models/_complex_request_configs.py +47 -0
- package/tests/expected/complex/tea_python_tests/models/_complex_request_header.py +42 -0
- package/tests/expected/complex/tea_python_tests/models/_complex_request_part.py +33 -0
- package/tests/expected/complex/tea_python_tests/models/_response.py +33 -0
- package/tests/expected/model/tea_python_tests/exceptions/__init__.py +11 -0
- package/tests/expected/model/tea_python_tests/{exceptions.py → exceptions/_main_file.py} +1 -1
- package/tests/expected/model/tea_python_tests/models/__init__.py +33 -0
- package/tests/expected/model/tea_python_tests/models/_class.py +24 -0
- package/tests/expected/model/tea_python_tests/models/_m.py +38 -0
- package/tests/expected/model/tea_python_tests/models/_main_file_model.py +45 -0
- package/tests/expected/model/tea_python_tests/models/_main_file_model_model.py +32 -0
- package/tests/expected/model/tea_python_tests/models/_model.py +32 -0
- package/tests/expected/model/tea_python_tests/models/_msub_m.py +26 -0
- package/tests/expected/model/tea_python_tests/{models.py → models/_my_model.py} +16 -321
- package/tests/expected/model/tea_python_tests/models/_my_model_model.py +45 -0
- package/tests/expected/model/tea_python_tests/models/_my_model_model_model.py +32 -0
- package/tests/expected/model/tea_python_tests/models/_my_model_subarraymodel.py +24 -0
- package/tests/expected/model/tea_python_tests/models/_my_model_submodel.py +45 -0
- package/tests/expected/model/tea_python_tests/models/_my_model_submodel_model.py +32 -0
- package/tests/expected/multi/tea_python_tests/api.py +0 -2
- package/tests/expected/multi/tea_python_tests/api_models/__init__.py +11 -0
- package/tests/expected/{python3/annotation/tea_python_tests/models.py → multi/tea_python_tests/api_models/_test_model_dir_2.py} +7 -9
- package/tests/expected/multi/tea_python_tests/client.py +0 -2
- package/tests/expected/multi/tea_python_tests/exceptions/__init__.py +13 -0
- package/tests/{output/complex/tea_python_tests/exceptions.py → expected/multi/tea_python_tests/exceptions/_err.py} +10 -11
- package/tests/expected/multi/tea_python_tests/model/user_exceptions/__init__.py +15 -0
- package/tests/expected/multi/tea_python_tests/model/user_exceptions/_err.py +22 -0
- package/tests/expected/multi/tea_python_tests/model/{user_exceptions.py → user_exceptions/_err_1.py} +3 -32
- package/tests/expected/multi/tea_python_tests/model/user_exceptions/_err_2.py +18 -0
- package/tests/expected/multi/tea_python_tests/model/user_models/__init__.py +13 -0
- package/tests/expected/multi/tea_python_tests/model/user_models/_base_info.py +72 -0
- package/tests/expected/multi/tea_python_tests/model/{user_models.py → user_models/_info.py} +3 -69
- package/tests/expected/multi/tea_python_tests/models/__init__.py +13 -0
- package/tests/expected/multi/tea_python_tests/models/_test_model_dir.py +79 -0
- package/tests/expected/{python2/empty/tea_python_tests/client.py → typedef/tea_python_tests/models/__init__.py} +9 -3
- package/tests/{output/typedef/tea_python_tests/models.py → expected/typedef/tea_python_tests/models/_m.py} +1 -1
- package/tests/fixtures/multi/api.dara +4 -0
- package/tests/fixtures/multi/main.dara +18 -0
- package/tests/main.tests.js +194 -219
- package/tests/output/annotation/tea_python_tests/models/__init__.py +11 -0
- package/tests/output/annotation/tea_python_tests/{models.py → models/_test.py} +1 -1
- package/tests/output/comment/tea_python_tests/models/__init__.py +15 -0
- package/tests/output/comment/tea_python_tests/models/_test_1.py +91 -0
- package/tests/output/comment/tea_python_tests/models/_test_2.py +55 -0
- package/tests/output/comment/tea_python_tests/models/_test_3.py +61 -0
- package/tests/output/complex/tea_python_tests/client.py +6 -6
- package/tests/output/complex/tea_python_tests/exceptions/__init__.py +13 -0
- package/tests/output/complex/tea_python_tests/exceptions/_err_1.py +23 -0
- package/tests/output/complex/tea_python_tests/exceptions/_err_2.py +22 -0
- package/tests/output/complex/tea_python_tests/models/__init__.py +19 -0
- package/tests/{expected/complex/tea_python_tests/models.py → output/complex/tea_python_tests/models/_complex_request.py} +12 -141
- package/tests/output/complex/tea_python_tests/models/_complex_request_configs.py +47 -0
- package/tests/output/complex/tea_python_tests/models/_complex_request_header.py +42 -0
- package/tests/output/complex/tea_python_tests/models/_complex_request_part.py +33 -0
- package/tests/output/complex/tea_python_tests/models/_response.py +33 -0
- package/tests/output/model/tea_python_tests/exceptions/__init__.py +11 -0
- package/tests/output/model/tea_python_tests/{exceptions.py → exceptions/_main_file.py} +1 -1
- package/tests/output/model/tea_python_tests/models/__init__.py +33 -0
- package/tests/output/model/tea_python_tests/models/_class.py +24 -0
- package/tests/output/model/tea_python_tests/models/_m.py +38 -0
- package/tests/output/model/tea_python_tests/models/_main_file_model.py +45 -0
- package/tests/output/model/tea_python_tests/models/_main_file_model_model.py +32 -0
- package/tests/output/model/tea_python_tests/models/_model.py +32 -0
- package/tests/output/model/tea_python_tests/models/_msub_m.py +26 -0
- package/tests/output/model/tea_python_tests/{models.py → models/_my_model.py} +16 -321
- package/tests/output/model/tea_python_tests/models/_my_model_model.py +45 -0
- package/tests/output/model/tea_python_tests/models/_my_model_model_model.py +32 -0
- package/tests/output/model/tea_python_tests/models/_my_model_subarraymodel.py +24 -0
- package/tests/output/model/tea_python_tests/models/_my_model_submodel.py +45 -0
- package/tests/output/model/tea_python_tests/models/_my_model_submodel_model.py +32 -0
- package/tests/output/multi/tea_python_tests/api.py +0 -2
- package/tests/output/multi/tea_python_tests/api_models/__init__.py +11 -0
- package/tests/{expected/python2/annotation/tea_python_tests/models.py → output/multi/tea_python_tests/api_models/_test_model_dir_2.py} +12 -11
- package/tests/output/multi/tea_python_tests/client.py +0 -2
- package/tests/output/multi/tea_python_tests/exceptions/__init__.py +13 -0
- package/tests/{expected/complex/tea_python_tests/exceptions.py → output/multi/tea_python_tests/exceptions/_err.py} +10 -11
- package/tests/output/multi/tea_python_tests/model/user_exceptions/__init__.py +15 -0
- package/tests/output/multi/tea_python_tests/model/user_exceptions/_err.py +22 -0
- package/tests/output/multi/tea_python_tests/model/{user_exceptions.py → user_exceptions/_err_1.py} +3 -32
- package/tests/output/multi/tea_python_tests/model/user_exceptions/_err_2.py +18 -0
- package/tests/output/multi/tea_python_tests/model/user_models/__init__.py +13 -0
- package/tests/output/multi/tea_python_tests/model/user_models/_base_info.py +72 -0
- package/tests/output/multi/tea_python_tests/model/{user_models.py → user_models/_info.py} +3 -69
- package/tests/output/multi/tea_python_tests/models/__init__.py +13 -0
- package/tests/output/multi/tea_python_tests/models/_test_model_dir.py +79 -0
- package/tests/{expected/python2/model/tea_python_tests/client.py → output/typedef/tea_python_tests/models/__init__.py} +9 -3
- package/tests/{expected/typedef/tea_python_tests/models.py → output/typedef/tea_python_tests/models/_m.py} +1 -1
- package/tests/expected/comment/tea_python_tests/models.py +0 -195
- package/tests/expected/python2/alias/setup.py +0 -79
- package/tests/expected/python2/alias/tea_python_tests/client.py +0 -23
- package/tests/expected/python2/annotation/tea_python_tests/client.py +0 -54
- package/tests/expected/python2/api/tea_python_tests/client.py +0 -54
- package/tests/expected/python2/comment/tea_python_tests/client.py +0 -188
- package/tests/expected/python2/comment/tea_python_tests/models.py +0 -146
- package/tests/expected/python2/complex/tea_python_tests/client.py +0 -301
- package/tests/expected/python2/complex/tea_python_tests/models.py +0 -315
- package/tests/expected/python2/const/tea_python_tests/client.py +0 -14
- package/tests/expected/python2/empty/setup.py +0 -76
- package/tests/expected/python2/exec/tea_python_tests/exec_client.py +0 -16
- package/tests/expected/python2/function/tea_python_tests/client.py +0 -47
- package/tests/expected/python2/import/setup.py +0 -85
- package/tests/expected/python2/import/tea_python_tests/client.py +0 -24
- package/tests/expected/python2/map/tea_python_tests/client.py +0 -19
- package/tests/expected/python2/model/tea_python_tests/models.py +0 -575
- package/tests/expected/python2/statements/tea_python_tests/client.py +0 -64
- package/tests/expected/python2/super/tea_python_tests/client.py +0 -8
- package/tests/expected/python2/typedef/setup.py +0 -85
- package/tests/expected/python2/typedef/tea_python_tests/client.py +0 -38
- package/tests/expected/python2/typedef/tea_python_tests/models.py +0 -35
- package/tests/expected/python3/alias/setup.py +0 -77
- package/tests/expected/python3/alias/tea_python_tests/client.py +0 -32
- package/tests/expected/python3/annotation/tea_python_tests/client.py +0 -88
- package/tests/expected/python3/api/tea_python_tests/client.py +0 -92
- package/tests/expected/python3/comment/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/comment/tea_python_tests/client.py +0 -319
- package/tests/expected/python3/comment/tea_python_tests/models.py +0 -163
- package/tests/expected/python3/complex/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/complex/tea_python_tests/client.py +0 -514
- package/tests/expected/python3/complex/tea_python_tests/models.py +0 -349
- package/tests/expected/python3/const/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/const/tea_python_tests/client.py +0 -9
- package/tests/expected/python3/empty/setup.py +0 -74
- package/tests/expected/python3/empty/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/empty/tea_python_tests/client.py +0 -5
- package/tests/expected/python3/exec/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/exec/tea_python_tests/exec_client.py +0 -20
- package/tests/expected/python3/function/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/function/tea_python_tests/client.py +0 -67
- package/tests/expected/python3/import/setup.py +0 -77
- package/tests/expected/python3/import/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/import/tea_python_tests/client.py +0 -28
- package/tests/expected/python3/map/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/map/tea_python_tests/client.py +0 -22
- package/tests/expected/python3/model/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/model/tea_python_tests/models.py +0 -631
- package/tests/expected/python3/statements/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/statements/tea_python_tests/client.py +0 -83
- package/tests/expected/python3/super/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/super/tea_python_tests/client.py +0 -13
- package/tests/expected/python3/typedef/setup.py +0 -77
- package/tests/expected/python3/typedef/tea_python_tests/__init__.py +0 -1
- package/tests/expected/python3/typedef/tea_python_tests/client.py +0 -72
- package/tests/expected/python3/typedef/tea_python_tests/models.py +0 -39
- package/tests/output/comment/tea_python_tests/models.py +0 -195
- /package/tests/expected/{python2/alias → multi}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/annotation → output/alias}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/api → output/annotation}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/comment → output/api}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/complex → output/builtin}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/const → output/comment}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/empty → output/complex}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/exec → output/const}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/function → output/empty}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/import → output/exec}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/map → output/function}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/model → output/import}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/statements → output/map}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/super → output/model}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python2/typedef → output/multi}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python3/alias → output/statements}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python3/annotation → output/super}/tea_python_tests/__init__.py +0 -0
- /package/tests/{expected/python3/api → output/typedef}/tea_python_tests/__init__.py +0 -0
package/tests/main.tests.js
CHANGED
|
@@ -14,7 +14,33 @@ const expectedDir = path.join(__dirname, 'expected/');
|
|
|
14
14
|
const fixturesDir = path.join(__dirname, 'fixtures/');
|
|
15
15
|
const outputDir = path.join(__dirname, 'output/');
|
|
16
16
|
|
|
17
|
-
function
|
|
17
|
+
function compareDirectories(expectedDir, outputDir) {
|
|
18
|
+
const expectedFiles = fs.readdirSync(expectedDir);
|
|
19
|
+
const outputFiles = fs.readdirSync(outputDir);
|
|
20
|
+
for (let fileName of expectedFiles) {
|
|
21
|
+
if (!outputFiles.includes(fileName)) {
|
|
22
|
+
assert.ok(false);
|
|
23
|
+
}
|
|
24
|
+
const expectedPath = path.join(outputDir, fileName);
|
|
25
|
+
const actualPath = path.join(expectedDir, fileName);
|
|
26
|
+
const expectedStat = fs.statSync(expectedPath);
|
|
27
|
+
const actualStat = fs.statSync(actualPath);
|
|
28
|
+
|
|
29
|
+
// 如果两个文件都是文件夹,则递归进行比较
|
|
30
|
+
if (expectedStat.isDirectory() && actualStat.isDirectory()) {
|
|
31
|
+
compareDirectories(expectedPath, actualPath);
|
|
32
|
+
}
|
|
33
|
+
// 如果是文件,则比较文件内容
|
|
34
|
+
else if (expectedStat.isFile() && actualStat.isFile()) {
|
|
35
|
+
const expectedContent = fs.readFileSync(expectedPath, 'utf8');
|
|
36
|
+
const acutalContent = fs.readFileSync(actualPath, 'utf8');
|
|
37
|
+
|
|
38
|
+
assert.deepStrictEqual(expectedContent, acutalContent);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function check(moduleName, expectedDir, option = {}) {
|
|
18
44
|
const mainFilePath = path.join(fixturesDir, moduleName, 'main.dara') ? path.join(fixturesDir, moduleName, 'main.dara') : path.join(fixturesDir, moduleName, 'main.tea');
|
|
19
45
|
const moduleOutputDir = path.join(outputDir, moduleName);
|
|
20
46
|
const prefixDir = path.join(fixturesDir, moduleName);
|
|
@@ -34,195 +60,158 @@ function check(moduleName, expectedFiles = [], option = {}) {
|
|
|
34
60
|
const dsl = fs.readFileSync(mainFilePath, 'utf8');
|
|
35
61
|
const ast = DSL.parse(dsl, mainFilePath);
|
|
36
62
|
generator.visit(ast);
|
|
37
|
-
|
|
38
|
-
const outputFilePath = path.join(outputDir, moduleName, element);
|
|
39
|
-
const expectedFilePath = path.join(expectedDir, moduleName, element);
|
|
40
|
-
const expected = fs.readFileSync(expectedFilePath, 'utf8');
|
|
41
|
-
assert.deepStrictEqual(fs.readFileSync(outputFilePath, 'utf8'), expected);
|
|
42
|
-
});
|
|
63
|
+
compareDirectories(path.join(__dirname, 'expected', moduleName, expectedDir), path.join(moduleOutputDir, expectedDir));
|
|
43
64
|
}
|
|
44
65
|
|
|
45
66
|
describe('Python Generator', function () {
|
|
46
67
|
|
|
47
68
|
it('multi should ok', function () {
|
|
48
|
-
check('multi',
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
],
|
|
56
|
-
{
|
|
57
|
-
python: {
|
|
58
|
-
package: 'tea_python_tests',
|
|
59
|
-
clientName: 'client'
|
|
60
|
-
}
|
|
61
|
-
});
|
|
69
|
+
check('multi', 'tea_python_tests',
|
|
70
|
+
{
|
|
71
|
+
python: {
|
|
72
|
+
package: 'tea_python_tests',
|
|
73
|
+
clientName: 'client'
|
|
74
|
+
}
|
|
75
|
+
});
|
|
62
76
|
});
|
|
63
77
|
|
|
64
78
|
|
|
65
79
|
it('complex should ok', function () {
|
|
66
|
-
check('complex',
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
clientName: 'client'
|
|
74
|
-
}
|
|
75
|
-
});
|
|
80
|
+
check('complex', 'tea_python_tests',
|
|
81
|
+
{
|
|
82
|
+
python: {
|
|
83
|
+
package: 'tea_python_tests',
|
|
84
|
+
clientName: 'client'
|
|
85
|
+
}
|
|
86
|
+
});
|
|
76
87
|
});
|
|
77
88
|
|
|
78
89
|
it('model should ok', function () {
|
|
79
|
-
check('model',
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
});
|
|
90
|
+
check('model', 'tea_python_tests',
|
|
91
|
+
{
|
|
92
|
+
python: {
|
|
93
|
+
package: 'tea_python_tests',
|
|
94
|
+
clientName: 'client',
|
|
95
|
+
additionalPackage: [
|
|
96
|
+
{
|
|
97
|
+
from: '__future__',
|
|
98
|
+
import: 'annotations'
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
});
|
|
96
103
|
});
|
|
97
104
|
|
|
98
105
|
it('map should ok', function () {
|
|
99
|
-
check('map',
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
});
|
|
106
|
+
check('map', 'tea_python_tests',
|
|
107
|
+
{
|
|
108
|
+
python: {
|
|
109
|
+
package: 'tea_python_tests',
|
|
110
|
+
clientName: 'client'
|
|
111
|
+
}
|
|
112
|
+
});
|
|
108
113
|
});
|
|
109
114
|
|
|
110
115
|
it('builtin should ok', function () {
|
|
111
|
-
check('builtin',
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
});
|
|
116
|
+
check('builtin', 'tea_python_tests',
|
|
117
|
+
{
|
|
118
|
+
exec: true,
|
|
119
|
+
python: {
|
|
120
|
+
package: 'tea_python_tests',
|
|
121
|
+
clientName: 'client'
|
|
122
|
+
}
|
|
123
|
+
});
|
|
121
124
|
});
|
|
122
125
|
|
|
123
126
|
it('exec should ok', function () {
|
|
124
|
-
check('exec',
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
});
|
|
127
|
+
check('exec', 'tea_python_tests',
|
|
128
|
+
{
|
|
129
|
+
exec: true,
|
|
130
|
+
python: {
|
|
131
|
+
package: 'tea_python_tests',
|
|
132
|
+
clientName: 'exec_client'
|
|
133
|
+
}
|
|
134
|
+
});
|
|
134
135
|
});
|
|
135
136
|
|
|
136
137
|
it('alias should ok', function () {
|
|
137
|
-
check('alias',
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
email: 'sdk-team@alibabacloud.com'
|
|
138
|
+
check('alias', 'tea_python_tests',
|
|
139
|
+
{
|
|
140
|
+
python: {
|
|
141
|
+
package: 'tea_python_tests',
|
|
142
|
+
clientName: 'client',
|
|
143
|
+
packageInfo: {
|
|
144
|
+
name: 'tea_python_tests',
|
|
145
|
+
desc: 'Generate setup.py',
|
|
146
|
+
github: 'https://github.com/',
|
|
147
|
+
author: 'Alibaba',
|
|
148
|
+
email: 'sdk-team@alibabacloud.com'
|
|
149
|
+
}
|
|
150
150
|
}
|
|
151
|
-
}
|
|
152
|
-
});
|
|
151
|
+
});
|
|
153
152
|
});
|
|
154
153
|
|
|
155
154
|
it('const should ok', function () {
|
|
156
|
-
check('const',
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
});
|
|
155
|
+
check('const', 'tea_python_tests',
|
|
156
|
+
{
|
|
157
|
+
python: {
|
|
158
|
+
package: 'tea_python_tests',
|
|
159
|
+
clientName: 'client'
|
|
160
|
+
}
|
|
161
|
+
});
|
|
165
162
|
});
|
|
166
163
|
|
|
167
164
|
it('statements should ok', function () {
|
|
168
|
-
check('statements',
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
});
|
|
165
|
+
check('statements', 'tea_python_tests',
|
|
166
|
+
{
|
|
167
|
+
python: {
|
|
168
|
+
package: 'tea_python_tests',
|
|
169
|
+
clientName: 'client'
|
|
170
|
+
}
|
|
171
|
+
});
|
|
177
172
|
});
|
|
178
173
|
|
|
179
174
|
it('function should ok', function () {
|
|
180
|
-
check('function',
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
});
|
|
175
|
+
check('function', 'tea_python_tests',
|
|
176
|
+
{
|
|
177
|
+
python: {
|
|
178
|
+
package: 'tea_python_tests',
|
|
179
|
+
clientName: 'client'
|
|
180
|
+
}
|
|
181
|
+
});
|
|
189
182
|
});
|
|
190
183
|
|
|
191
184
|
it('api should ok', function () {
|
|
192
|
-
check('api',
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
});
|
|
185
|
+
check('api', 'tea_python_tests',
|
|
186
|
+
{
|
|
187
|
+
python: {
|
|
188
|
+
package: 'tea_python_tests',
|
|
189
|
+
clientName: 'client'
|
|
190
|
+
}
|
|
191
|
+
});
|
|
201
192
|
});
|
|
202
193
|
|
|
203
194
|
it('import should ok', function () {
|
|
204
|
-
check('import',
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
});
|
|
195
|
+
check('import', 'tea_python_tests',
|
|
196
|
+
{
|
|
197
|
+
python: {
|
|
198
|
+
package: 'tea_python_tests',
|
|
199
|
+
clientName: 'client',
|
|
200
|
+
packageInfo: {
|
|
201
|
+
name: 'tea_python_tests',
|
|
202
|
+
desc: 'Generate setup.py',
|
|
203
|
+
github: 'https://github.com/',
|
|
204
|
+
author: 'Alibaba',
|
|
205
|
+
email: 'sdk-team@alibabacloud.com'
|
|
206
|
+
},
|
|
207
|
+
additionalPackage: [
|
|
208
|
+
{
|
|
209
|
+
from: '__future__',
|
|
210
|
+
import: 'annotations'
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
});
|
|
226
215
|
const expected = fs.readFileSync(path.join(expectedDir, 'import', 'setup.py'), 'utf8');
|
|
227
216
|
const output = fs.readFileSync(path.join(outputDir, 'import', 'setup.py'), 'utf8');
|
|
228
217
|
assert.deepStrictEqual(output.replace(new RegExp('\\d{2}\\/\\d{2}\\/\\d{4}'), '*'), expected);
|
|
@@ -231,38 +220,29 @@ describe('Python Generator', function () {
|
|
|
231
220
|
|
|
232
221
|
|
|
233
222
|
it('add annotation should ok', function () {
|
|
234
|
-
check('annotation',
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
clientName: 'client'
|
|
242
|
-
}
|
|
243
|
-
});
|
|
223
|
+
check('annotation', 'tea_python_tests',
|
|
224
|
+
{
|
|
225
|
+
python: {
|
|
226
|
+
package: 'tea_python_tests',
|
|
227
|
+
clientName: 'client'
|
|
228
|
+
}
|
|
229
|
+
});
|
|
244
230
|
});
|
|
245
231
|
|
|
246
232
|
it('add comments should ok', function () {
|
|
247
|
-
check('comment',
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
clientName: 'client'
|
|
255
|
-
}
|
|
256
|
-
});
|
|
233
|
+
check('comment', 'tea_python_tests',
|
|
234
|
+
{
|
|
235
|
+
python: {
|
|
236
|
+
package: 'tea_python_tests',
|
|
237
|
+
clientName: 'client'
|
|
238
|
+
}
|
|
239
|
+
});
|
|
257
240
|
});
|
|
258
241
|
|
|
259
242
|
|
|
260
243
|
|
|
261
244
|
it('empty should ok', function () {
|
|
262
|
-
check('empty',
|
|
263
|
-
'tea_python_tests/client.py',
|
|
264
|
-
// '.gitignore'
|
|
265
|
-
],
|
|
245
|
+
check('empty', 'tea_python_tests',
|
|
266
246
|
{
|
|
267
247
|
python: {
|
|
268
248
|
package: 'tea_python_tests',
|
|
@@ -281,57 +261,52 @@ describe('Python Generator', function () {
|
|
|
281
261
|
|
|
282
262
|
|
|
283
263
|
it('super should ok', function () {
|
|
284
|
-
check('super',
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
});
|
|
264
|
+
check('super', 'tea_python_tests',
|
|
265
|
+
{
|
|
266
|
+
python: {
|
|
267
|
+
package: 'tea_python_tests',
|
|
268
|
+
clientName: 'client'
|
|
269
|
+
}
|
|
270
|
+
});
|
|
293
271
|
});
|
|
294
272
|
|
|
295
273
|
|
|
296
274
|
it('typedef should ok', function () {
|
|
297
|
-
check('typedef',
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
github: 'https://github.com/',
|
|
309
|
-
author: 'Alibaba',
|
|
310
|
-
email: 'sdk-team@alibabacloud.com'
|
|
311
|
-
},
|
|
312
|
-
typedef: {
|
|
313
|
-
HttpResponse: {
|
|
314
|
-
import: 'requests',
|
|
315
|
-
type: 'Response',
|
|
316
|
-
package: 'requests:2.21.0'
|
|
317
|
-
},
|
|
318
|
-
HttpHeader: {
|
|
319
|
-
import: null,
|
|
320
|
-
type: 'Dict[str, Any]',
|
|
321
|
-
package: null
|
|
275
|
+
check('typedef', 'tea_python_tests',
|
|
276
|
+
{
|
|
277
|
+
python: {
|
|
278
|
+
package: 'tea_python_tests',
|
|
279
|
+
clientName: 'client',
|
|
280
|
+
packageInfo: {
|
|
281
|
+
name: 'tea_python_tests',
|
|
282
|
+
desc: 'Generate setup.py',
|
|
283
|
+
github: 'https://github.com/',
|
|
284
|
+
author: 'Alibaba',
|
|
285
|
+
email: 'sdk-team@alibabacloud.com'
|
|
322
286
|
},
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
287
|
+
typedef: {
|
|
288
|
+
HttpResponse: {
|
|
289
|
+
import: 'requests',
|
|
290
|
+
type: 'Response',
|
|
291
|
+
package: 'requests:2.21.0'
|
|
292
|
+
},
|
|
293
|
+
HttpHeader: {
|
|
294
|
+
import: null,
|
|
295
|
+
type: 'Dict[str, Any]',
|
|
296
|
+
package: null
|
|
297
|
+
},
|
|
298
|
+
TeaModel: {
|
|
299
|
+
import: 'Tea.model',
|
|
300
|
+
type: 'TeaModel',
|
|
301
|
+
package: 'alibabacloud-tea:0.2.9'
|
|
302
|
+
},
|
|
303
|
+
TeaException: {
|
|
304
|
+
import: 'Tea.exceptions',
|
|
305
|
+
type: 'TeaException',
|
|
306
|
+
package: 'alibabacloud-tea:0.2.9'
|
|
307
|
+
}
|
|
332
308
|
}
|
|
333
309
|
}
|
|
334
|
-
}
|
|
335
|
-
});
|
|
310
|
+
});
|
|
336
311
|
});
|
|
337
312
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
from ._test_1 import Test1
|
|
8
|
+
from ._test_2 import Test2
|
|
9
|
+
from ._test_3 import Test3
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
Test1,
|
|
13
|
+
Test2,
|
|
14
|
+
Test3
|
|
15
|
+
]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from darabonba.model import DaraModel
|
|
5
|
+
from typing import List
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# import comment
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
"""
|
|
12
|
+
* @remarks
|
|
13
|
+
* TestModel
|
|
14
|
+
"""
|
|
15
|
+
class Test1(DaraModel):
|
|
16
|
+
def __init__(
|
|
17
|
+
self, *,
|
|
18
|
+
test: str = None,
|
|
19
|
+
# odel的test back comment
|
|
20
|
+
test_2: str = None,
|
|
21
|
+
# odel的test2 back comment
|
|
22
|
+
test_3: List[List[str]] = None,
|
|
23
|
+
test_5: str = None,
|
|
24
|
+
sts: str = None,
|
|
25
|
+
a_sts: str = None,
|
|
26
|
+
):
|
|
27
|
+
# test desc
|
|
28
|
+
self.test = test
|
|
29
|
+
# odel的test back comment
|
|
30
|
+
# test2 desc
|
|
31
|
+
self.test_2 = test_2
|
|
32
|
+
# odel的test2 back comment
|
|
33
|
+
# test3 desc
|
|
34
|
+
self.test_3 = test_3
|
|
35
|
+
# test desc
|
|
36
|
+
self.test_5 = test_5
|
|
37
|
+
# sts desc
|
|
38
|
+
self.sts = sts
|
|
39
|
+
# asts desc
|
|
40
|
+
self.a_sts = a_sts
|
|
41
|
+
|
|
42
|
+
def validate(self):
|
|
43
|
+
self.validate_required(self.test, 'test')
|
|
44
|
+
# odel的test back comment
|
|
45
|
+
self.validate_required(self.test_2, 'test_2')
|
|
46
|
+
# odel的test2 back comment
|
|
47
|
+
self.validate_required(self.test_3, 'test_3')
|
|
48
|
+
self.validate_required(self.test_5, 'test_5')
|
|
49
|
+
self.validate_required(self.sts, 'sts')
|
|
50
|
+
self.validate_required(self.a_sts, 'a_sts')
|
|
51
|
+
|
|
52
|
+
def to_map(self):
|
|
53
|
+
_map = super().to_map()
|
|
54
|
+
if _map is not None:
|
|
55
|
+
return _map
|
|
56
|
+
|
|
57
|
+
result = dict()
|
|
58
|
+
if self.test is not None:
|
|
59
|
+
result['test'] = self.test
|
|
60
|
+
# odel的test back comment
|
|
61
|
+
if self.test_2 is not None:
|
|
62
|
+
result['test2'] = self.test_2
|
|
63
|
+
# odel的test2 back comment
|
|
64
|
+
if self.test_3 is not None:
|
|
65
|
+
result['test3'] = self.test_3
|
|
66
|
+
if self.test_5 is not None:
|
|
67
|
+
result['test5'] = self.test_5
|
|
68
|
+
if self.sts is not None:
|
|
69
|
+
result['sts'] = self.sts
|
|
70
|
+
if self.a_sts is not None:
|
|
71
|
+
result['asts'] = self.a_sts
|
|
72
|
+
return result
|
|
73
|
+
|
|
74
|
+
def from_map(self, m: dict = None):
|
|
75
|
+
m = m or dict()
|
|
76
|
+
if m.get('test') is not None:
|
|
77
|
+
self.test = m.get('test')
|
|
78
|
+
# odel的test back comment
|
|
79
|
+
if m.get('test2') is not None:
|
|
80
|
+
self.test_2 = m.get('test2')
|
|
81
|
+
# odel的test2 back comment
|
|
82
|
+
if m.get('test3') is not None:
|
|
83
|
+
self.test_3 = m.get('test3')
|
|
84
|
+
if m.get('test5') is not None:
|
|
85
|
+
self.test_5 = m.get('test5')
|
|
86
|
+
if m.get('sts') is not None:
|
|
87
|
+
self.sts = m.get('sts')
|
|
88
|
+
if m.get('asts') is not None:
|
|
89
|
+
self.a_sts = m.get('asts')
|
|
90
|
+
return self
|
|
91
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from darabonba.model import DaraModel
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
* @remarks
|
|
9
|
+
* TestModel2
|
|
10
|
+
"""
|
|
11
|
+
class Test2(DaraModel):
|
|
12
|
+
def __init__(
|
|
13
|
+
self, *,
|
|
14
|
+
# model的test front comment
|
|
15
|
+
test: str = None,
|
|
16
|
+
# model的test front comment
|
|
17
|
+
test_2: str = None,
|
|
18
|
+
):
|
|
19
|
+
# model的test front comment
|
|
20
|
+
# test desc
|
|
21
|
+
self.test = test
|
|
22
|
+
# model的test front comment
|
|
23
|
+
# test2 desc
|
|
24
|
+
self.test_2 = test_2
|
|
25
|
+
|
|
26
|
+
def validate(self):
|
|
27
|
+
# model的test front comment
|
|
28
|
+
self.validate_required(self.test, 'test')
|
|
29
|
+
# model的test front comment
|
|
30
|
+
self.validate_required(self.test_2, 'test_2')
|
|
31
|
+
|
|
32
|
+
def to_map(self):
|
|
33
|
+
_map = super().to_map()
|
|
34
|
+
if _map is not None:
|
|
35
|
+
return _map
|
|
36
|
+
|
|
37
|
+
result = dict()
|
|
38
|
+
# model的test front comment
|
|
39
|
+
if self.test is not None:
|
|
40
|
+
result['test'] = self.test
|
|
41
|
+
# model的test front comment
|
|
42
|
+
if self.test_2 is not None:
|
|
43
|
+
result['test2'] = self.test_2
|
|
44
|
+
return result
|
|
45
|
+
|
|
46
|
+
def from_map(self, m: dict = None):
|
|
47
|
+
m = m or dict()
|
|
48
|
+
# model的test front comment
|
|
49
|
+
if m.get('test') is not None:
|
|
50
|
+
self.test = m.get('test')
|
|
51
|
+
# model的test front comment
|
|
52
|
+
if m.get('test2') is not None:
|
|
53
|
+
self.test_2 = m.get('test2')
|
|
54
|
+
return self
|
|
55
|
+
|