-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-candidate' into release
- Loading branch information
Showing
4 changed files
with
113 additions
and
18 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,23 @@ | ||
name: Run tests | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.8, 3.11] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip . | ||
- name: Run tests | ||
run: | | ||
python -m unittest |
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 |
---|---|---|
@@ -1 +1 @@ | ||
0.2.4.2 | ||
0.2.4.3 |
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,86 @@ | ||
import json | ||
import subprocess | ||
import unittest | ||
|
||
|
||
# ufbt invokation & json status output | ||
def ufbt_status() -> dict: | ||
# Call "ufbt status --json" and return the parsed json | ||
try: | ||
status = subprocess.check_output(["ufbt", "status", "--json"]) | ||
except subprocess.CalledProcessError as e: | ||
status = e.output | ||
return json.loads(status) | ||
|
||
|
||
def ufbt_exec(args): | ||
# Call "ufbt" with the given args and return the parsed json | ||
return subprocess.check_output(["ufbt"] + args) | ||
|
||
|
||
# Test initial deployment | ||
class TestInitialDeployment(unittest.TestCase): | ||
def test_default_deployment(self): | ||
ufbt_exec(["clean"]) | ||
status = ufbt_status() | ||
self.assertEqual(status.get("error"), "SDK is not deployed") | ||
|
||
ufbt_exec(["update"]) | ||
status = ufbt_status() | ||
self.assertIsNone(status.get("error")) | ||
self.assertEqual(status.get("target"), "f7") | ||
self.assertEqual(status.get("mode"), "channel") | ||
self.assertEqual(status.get("details", {}).get("channel"), "release") | ||
|
||
def test_customized_deployment(self): | ||
ufbt_exec(["clean"]) | ||
status = ufbt_status() | ||
self.assertEqual(status.get("error"), "SDK is not deployed") | ||
|
||
ufbt_exec(["update", "-t", "f18", "-c", "rc"]) | ||
status = ufbt_status() | ||
self.assertIsNone(status.get("error")) | ||
self.assertEqual(status.get("target"), "f18") | ||
self.assertEqual(status.get("mode"), "channel") | ||
self.assertEqual(status.get("details", {}).get("channel"), "rc") | ||
self.assertIn("rc", status.get("version", "")) | ||
|
||
def test_target_switch(self): | ||
ufbt_exec(["clean"]) | ||
status = ufbt_status() | ||
self.assertEqual(status.get("error"), "SDK is not deployed") | ||
|
||
ufbt_exec(["update"]) | ||
status = ufbt_status() | ||
self.assertEqual(status.get("target"), "f7") | ||
|
||
ufbt_exec(["update", "-t", "f18"]) | ||
status = ufbt_status() | ||
self.assertEqual(status.get("target"), "f18") | ||
self.assertEqual(status.get("mode"), "channel") | ||
self.assertEqual(status.get("details", {}).get("channel"), "release") | ||
|
||
def test_target_mode_switches(self): | ||
ufbt_exec(["clean"]) | ||
status = ufbt_status() | ||
self.assertEqual(status.get("error"), "SDK is not deployed") | ||
|
||
ufbt_exec(["update"]) | ||
status = ufbt_status() | ||
self.assertEqual(status.get("target"), "f7") | ||
|
||
ufbt_exec(["update", "-t", "f18"]) | ||
status = ufbt_status() | ||
self.assertEqual(status.get("target"), "f18") | ||
self.assertEqual(status.get("mode"), "channel") | ||
|
||
ufbt_exec(["update", "-b", "dev"]) | ||
status = ufbt_status() | ||
self.assertEqual(status.get("target"), "f18") | ||
self.assertEqual(status.get("mode"), "branch") | ||
self.assertEqual(status.get("details", {}).get("branch"), "dev") | ||
|
||
previous_status = status | ||
ufbt_exec(["update"]) | ||
status = ufbt_status() | ||
self.assertEqual(previous_status, status) |
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