Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - OpenBB Platform CLI Unit tests #6397

Merged
merged 24 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
89db702
Unit test batch 1
IgorWounds May 12, 2024
4f684e1
CLI controller
IgorWounds May 12, 2024
8baa65c
Merge branch 'develop' into feature/cli-unit-tests
IgorWounds May 13, 2024
c9d7fe4
Merge branch 'develop' into feature/cli-unit-tests
IgorWounds May 13, 2024
deae7f8
Test batch 3
IgorWounds May 13, 2024
3dcf7c8
Test batch 4
IgorWounds May 13, 2024
03ff652
Test batch 5
IgorWounds May 13, 2024
8626b7f
Merge branch 'develop' into feature/cli-unit-tests
IgorWounds May 13, 2024
ba8e324
Merge branch 'develop' into feature/cli-unit-tests
hjoaquim May 14, 2024
725bff9
clean some workflows and setup actions
montezdesousa May 14, 2024
557889d
test
montezdesousa May 14, 2024
3ed3aa9
rename wfs
montezdesousa May 14, 2024
e39c1ee
Merge branch 'develop' into feature/cli-unit-tests
montezdesousa May 14, 2024
e25f2d3
rename
montezdesousa May 14, 2024
e9e1f50
Merge branch 'feature/cli-unit-tests' of github.com:OpenBB-finance/Op…
montezdesousa May 14, 2024
385cb33
update action
montezdesousa May 14, 2024
7679327
Merge branch 'develop' into feature/cli-unit-tests
IgorWounds May 14, 2024
590bc10
Skip
IgorWounds May 14, 2024
a9318c0
Merge branch 'develop' into feature/cli-unit-tests
montezdesousa May 14, 2024
0fd2f77
Merge branch 'develop' into feature/cli-unit-tests
hjoaquim May 14, 2024
1857c40
Merge remote-tracking branch 'OpenBB-finance/develop' into feature/cl…
hjoaquim May 14, 2024
119e309
fix cli tests
hjoaquim May 14, 2024
424735e
Merge branch 'feature/cli-unit-tests' of github.com:OpenBB-finance/Op…
hjoaquim May 14, 2024
bcdeae8
Merge branch 'develop' into feature/cli-unit-tests
hjoaquim May 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/scripts/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
PLATFORM_TESTS = [
str(PLATFORM_DIR / p) for p in ["tests", "core", "providers", "extensions"]
]
CLI_DIR = ROOT_DIR / "cli"
CLI_TESTS = CLI_DIR / "tests"


@nox.session(python=["3.9", "3.10", "3.11"])
def tests(session):
def unit_test_platform(session):
"""Run the test suite."""
session.install("poetry", "toml")
session.run(
Expand All @@ -27,3 +29,19 @@ def tests(session):
session.run(
"pytest", *PLATFORM_TESTS, f"--cov={PLATFORM_DIR}", "-m", "not integration"
)


@nox.session(python=["3.9", "3.10", "3.11"])
def unit_test_cli(session):
"""Run the test suite."""
session.install("poetry", "toml")
session.run(
"python",
str(PLATFORM_DIR / "dev_install.py"),
"-e",
"all",
external=True,
)
session.install("pytest")
session.install("pytest-cov")
session.run("pytest", CLI_TESTS, f"--cov={CLI_DIR}")
226 changes: 47 additions & 179 deletions .github/workflows/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy the OpenBB Platform and the OpenBBTerminal to Test PyPI
name: Deploy the OpenBB Platform to Test PyPI

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Drafter
name: Draft release

on:
workflow_dispatch:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: General Linting

env:
OPENBB_ENABLE_QUICK_EXIT: true
OPENBB_LOG_COLLECT: false
OPENBB_USE_PROMPT_TOOLKIT: false
OPENBB_FILE_OVERWRITE: true
PIP_DEFAULT_TIMEOUT: 100

on:
Expand Down
File renamed without changes.
27 changes: 0 additions & 27 deletions .github/workflows/labels-issue.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/nightly-build.yml

This file was deleted.

78 changes: 0 additions & 78 deletions .github/workflows/pypi.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: API Integration Tests
name: 🚉 Integration test Platform (API)

on:
workflow_dispatch:
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/test-unit-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 🖥️ Unit test CLI

on:
pull_request:
branches:
- develop
paths:
- 'cli/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
unit_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false

matrix:
python_version:
["3.9", "3.10", "3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Python ${{ matrix.python_version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
allow-prereleases: true
cache: "pip"

- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('cli/poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Run tests
run: |
pip install nox
nox -f .github/scripts/noxfile.py -s unit_test_cli --python ${{ matrix.python_version }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Platform V4
name: 🚉 Unit test Platform

on:
pull_request:
Expand Down Expand Up @@ -43,4 +43,4 @@ jobs:
- name: Run tests
run: |
pip install nox
nox -f .github/scripts/noxfile.py -s tests --python ${{ matrix.python_version }}
nox -f .github/scripts/noxfile.py -s unit_test_platform --python ${{ matrix.python_version }}
72 changes: 0 additions & 72 deletions .github/workflows/unit-test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:
"--ignore-words-list=VAI,MIS,shs,gard,te,commun,parana,ro,zar,vie,hel,jewl,zlot,ba,buil,coo,ether,hist,hsi,mape,navagation,operatio,pres,ser,yeld,shold,ist,varian,datas,ake,creat,statics,ket,toke,certi,buidl,ot,fo",
"--quiet-level=2",
"--skip=./**/tests/**,./**/test_*.py,.git,*.css,*.csv,*.html,*.ini,*.ipynb,*.js,*.json,*.lock,*.scss,*.txt,*.yaml,build/pyinstaller/*,./website/config.toml",
"-x=.github/workflows/linting.yml"
"-x=.github/workflows/general-linting.yml"
]
- repo: local
hooks:
Expand Down
14 changes: 0 additions & 14 deletions cli/openbb_cli/config/menu_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,6 @@ def add_raw(self, text: str, left_spacing: bool = False):
else:
self.menu_text += text

def add_section(
self, text: str, description: str = "", leading_new_line: bool = False
):
"""Append raw text (without translation)."""
spacing = (self.CMD_NAME_LENGTH - len(text) + self.SECTION_SPACING) * " "
if description:
text = f"{text}{spacing}{description}\n"

if leading_new_line:
self.menu_text += "\n" + text

else:
self.menu_text += text

def add_info(self, text: str):
"""Append information text (after translation)."""
self.menu_text += f"[info]{text}:[/info]\n"
Expand Down
Loading
Loading