Skip to content

Commit

Permalink
[Feature] - OpenBB Platform CLI Unit tests (#6397)
Browse files Browse the repository at this point in the history
* Unit test batch 1

* CLI controller

* Test batch 3

* Test batch 4

* Test batch 5

* clean some workflows and setup actions

* test

* rename wfs

* rename

* update action

* Skip

* fix cli tests

---------

Co-authored-by: Henrique Joaquim <henriquecjoaquim@gmail.com>
Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
  • Loading branch information
4 people authored May 14, 2024
1 parent f87c21e commit a116d9b
Show file tree
Hide file tree
Showing 35 changed files with 1,503 additions and 417 deletions.
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.

File renamed without changes.
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

0 comments on commit a116d9b

Please sign in to comment.