Files
OpenBB/tests/bots/common/test_helpers.py
Colin Delahunty dd4734bd90 Added Tests for Bots (#1523)
* Added common/helper tests

* expanded bot testing

* few changes

* import fix

* missed removing test config

* column order fix

* import fix

* removed df2img add new deps

* req

* update readme

* add dep for image export, fix

* get rid of yahoo-fin, add image export lib

* import issues in some machines fix

* images dir fix

* init fix

* fix?

* test

* test

* Fixed text handling

* missed a tbl

* Fixed tests

* Fixed poetry

* Fixed kaliedo

* Fixed codecov

* Fixed dependencies

* Added fix

* FIxed tests

* Added image cleanup

* Added tests

* Fixed tests

* Added test fix

* Added conda

* Updated bot path

* refactor

* poetry

* update dict/ fix slack image upload

* Update config_discordbot.py

* Updated

* Fixed tests

* Skipped energy

* fixes

* black

* fix

* import

* fix nan on smile

* added env settings

* add cmds_text dict, some chgs

* merge bot test fixes

* fix duplicate

Co-authored-by: teh_coderer <me@tehcoderer.com>
Co-authored-by: Colin Delahunty <colindelahunty@MacBook-Pro.local>
Co-authored-by: Chavithra <chavithra@gmail.com>
2022-03-25 18:21:41 -04:00

52 lines
1.4 KiB
Python

import pytest
from bots.common.helpers import get_arguments, get_syntax, non_slash, send_options
@pytest.mark.record_stdout
def test_send_options():
send_options("Commands", ["Option1", "Option2", "Option3"], lambda x: print(x))
def test_get_syntax():
value = get_syntax({"required": ["Option1", "Option2", "Option3"]}, "Command")
expected = "Command/Option1/Option2/Option3"
assert value == expected
@pytest.mark.parametrize(
"dictionary, cmd",
[
({}, "ticker"),
({}, "past_transactions_days"),
({}, "raw"),
({"required": {"Command": ["Option1", "Option2"]}}, "Command"),
({}, "expiry"),
],
)
@pytest.mark.record_stdout
def test_get_arguments(dictionary, cmd):
get_arguments(dictionary, cmd, lambda x: print(x))
@pytest.mark.vcr()
@pytest.mark.parametrize(
"text, value",
[
("text", False),
("!text", False),
("!dd", False),
("!candle", False),
("!candle/ewfewewfwe/1", False),
("!candle/tsla/12314121", False),
("!candle/tsla/1/20", True),
("!gov_contracts/tsla/15/True", True),
("!opt_cc_hist/tsla/2022-03-25/680/Calls", True),
],
)
@pytest.mark.record_stdout
def test_non_slash(text, value):
val = non_slash(
text, lambda x: print(x), lambda x, y, z: print(f"{x.__name__}{y}{z}")
)
assert val == value