-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated tests for Vehicle App Python Template (#186)
- Loading branch information
Showing
7 changed files
with
135 additions
and
15 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 @@ | ||
parameterized==0.9.0 |
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,36 @@ | ||
# Copyright (c) 2023 Robert Bosch GmbH | ||
|
||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0. | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import unittest | ||
from pathlib import Path | ||
|
||
import pkg_resources | ||
from parameterized import parameterized | ||
|
||
|
||
class TestRequirements(unittest.TestCase): | ||
"""Test availability of required packages.""" | ||
|
||
@parameterized.expand( | ||
["./requirements.txt", "./app/requirements.txt", "./app/tests/requirements.txt"] | ||
) | ||
def test_requirements(self, requirement_file_path): | ||
"""Test that each required package is available.""" | ||
requirements = pkg_resources.parse_requirements( | ||
Path(requirement_file_path).open() | ||
) | ||
for requirement in requirements: | ||
requirement = str(requirement) | ||
with self.subTest(requirement=requirement): | ||
pkg_resources.require(requirement) |
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,51 @@ | ||
# Copyright (c) 2023 Robert Bosch GmbH | ||
|
||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0. | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
import subprocess # nosec | ||
import unittest | ||
|
||
from parameterized import parameterized | ||
|
||
devenv_runtimes_path = ( | ||
subprocess.check_output(["velocitas", "package", "-p", "devenv-runtimes"]) # nosec | ||
.decode("utf-8") | ||
.strip("\n") | ||
) | ||
|
||
os.environ["VDB_PORT"] = "30555" | ||
os.environ["MQTT_PORT"] = "31883" | ||
|
||
|
||
class RuntimeTest(unittest.TestCase): | ||
@parameterized.expand(["runtime_k3d", "runtime_kanto", "runtime_local"]) | ||
def test_runtime(self, runtime): | ||
subprocess.check_call( # nosec | ||
[ | ||
"pytest", | ||
"-s", | ||
"-x", | ||
( | ||
f"{devenv_runtimes_path}/{runtime}/test/integration/" | ||
f"integration_test.py::test_scripts_run_successfully" | ||
), | ||
] | ||
) | ||
subprocess.check_call( # nosec | ||
["pytest", "-s", "-x", "./app/tests/integration/integration_test.py"] | ||
) | ||
if runtime != "runtime_local": | ||
subprocess.check_call( # nosec | ||
["velocitas", "exec", runtime.replace("_", "-"), "down"] | ||
) |
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,44 @@ | ||
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json | ||
# Copyright (c) 2023 Robert Bosch GmbH | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Devcontainer check | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
# Run only on branches/commits and not tags | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: "0 4 * * *" | ||
|
||
|
||
jobs: | ||
automated-tests: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build devcontainer and run automated tests | ||
uses: devcontainers/[email protected] | ||
with: | ||
runCmd: | | ||
pip3 install -r .devcontainer/tests/automated_tests/requirements.txt | ||
pytest -sx .devcontainer/tests |
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 |
---|---|---|
|
@@ -251,16 +251,3 @@ jobs: | |
name: "test-results" | ||
path: | | ||
results/Documentation/renderer/* | ||
devcontainer-check: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build and run dev container task | ||
uses: devcontainers/[email protected] | ||
with: | ||
runCmd: velocitas upgrade --dry-run | ||
push: never |
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