-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add python runtime tests (#1748)
- Loading branch information
Showing
8 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Runtime testing Python Models | ||
|
||
on: | ||
push: | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
paths: | ||
- 'src/generators/python/**' | ||
- 'test/runtime/runtime-python/**' | ||
jobs: | ||
test: | ||
name: Runtime testing Python Models | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Check package-lock version | ||
uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master | ||
id: lockversion | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '${{ steps.lockversion.outputs.version }}' | ||
cache: 'npm' | ||
cache-dependency-path: '**/package-lock.json' | ||
- name: Build library | ||
run: npm install && npm run build:prod | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
- name: Generate Python models | ||
run: npm run generate:runtime:python | ||
- name: Run runtime tests | ||
run: npm run test:runtime:python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { execCommand } from "../blackbox/utils/Utils"; | ||
import path from "path"; | ||
|
||
|
||
jest.setTimeout(50000); | ||
|
||
test("Python runtime testing", async () => { | ||
// The 'python ' command here | ||
|
||
const compileCommand = `cd ${path.resolve( | ||
__dirname, | ||
"./runtime-python/test/" | ||
)} && python3 main.py`; | ||
await execCommand(compileCommand,true); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { PYTHON_JSON_SERIALIZER_PRESET,PythonFileGenerator } from "../../"; | ||
import path from "path"; | ||
|
||
import input from "./generic-input.json"; | ||
|
||
const generator = new PythonFileGenerator({ | ||
presets: [PYTHON_JSON_SERIALIZER_PRESET], | ||
}); | ||
|
||
generator.generateToFiles( | ||
input, | ||
path.resolve( | ||
// eslint-disable-next-line no-undef | ||
__dirname, | ||
"./runtime-python/src/main/" | ||
), | ||
{} | ||
); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
myenv | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import unittest | ||
import sys | ||
sys.path.insert(1, '../src/main/') | ||
from Address import Address | ||
from NestedObject import NestedObject | ||
import json | ||
|
||
class TestAddress(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls) : | ||
cls.address = Address(input=type('obj', (object,),{ | ||
'streetName' : "Test address 2", | ||
'houseNumber' : 2, | ||
'marriage' : True, | ||
'members' : 2, | ||
'arrayType' : [2, "test"], | ||
'nestedObject' : NestedObject('test'), | ||
'enumTest' : 'TEST', | ||
'houseType' : 'DETACHED', | ||
'roofType' : 'TILE', | ||
|
||
|
||
})) | ||
|
||
|
||
def test_serializeToJson(self): | ||
json_str =self.address.serializeToJson() | ||
self.assertIsInstance(json_str, str) | ||
|
||
def test_should_not_contain_additional_properties_when_serialized(self): | ||
json_str = self.address.serializeToJson() | ||
self.assertNotIn('additionalProperties', json_str) | ||
|
||
|
||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters