diff --git a/.terminal.py.swp b/.terminal.py.swp new file mode 100644 index 00000000000..5031ee29223 Binary files /dev/null and b/.terminal.py.swp differ diff --git a/gamestonk_terminal/jupyter/dashboards/shortdata.ipynb b/gamestonk_terminal/jupyter/dashboards/shortdata.ipynb index 1ca74f876ed..04e1791cfb2 100644 --- a/gamestonk_terminal/jupyter/dashboards/shortdata.ipynb +++ b/gamestonk_terminal/jupyter/dashboards/shortdata.ipynb @@ -4,7 +4,10 @@ "cell_type": "code", "execution_count": 1, "metadata": { - "collapsed": true + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } }, "outputs": [], "source": [ @@ -22,6 +25,15 @@ { "cell_type": "code", "execution_count": 47, + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + }, + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "class ShortDataDash:\n", @@ -164,43 +176,51 @@ " self.ticker_button,\n", " self.output2,\n", " ]" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "code", "execution_count": 48, + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + }, + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "dash = ShortDataDash()\n", "app = widgets.VBox(\n", " dash.build_app(), layout=widgets.Layout(max_width=\"1024px\", margin=\"0 auto 0 auto\")\n", ")" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "code", "execution_count": 49, + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + }, + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "data": { - "text/plain": "VBox(children=(HTML(value=\"\\n
This widget downloads the consolidated NMS short da…", "application/vnd.jupyter.widget-view+json": { + "model_id": "dcda08c8d643465fb862d01341d71370", "version_major": 2, - "version_minor": 0, - "model_id": "dcda08c8d643465fb862d01341d71370" - } + "version_minor": 0 + }, + "text/plain": [ + "VBox(children=(HTML(value=\"\\n
This widget downloads the consolidated NMS short da…"
+ ]
},
"metadata": {},
"output_type": "display_data"
@@ -208,34 +228,28 @@
],
"source": [
"display(app)"
- ],
- "metadata": {
- "collapsed": false,
- "pycharm": {
- "name": "#%%\n"
- }
- }
+ ]
}
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
- "version": 2
+ "version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
- "pygments_lexer": "ipython2",
- "version": "2.7.6"
+ "pygments_lexer": "ipython3",
+ "version": "3.8.12"
}
},
"nbformat": 4,
- "nbformat_minor": 0
-}
\ No newline at end of file
+ "nbformat_minor": 4
+}
diff --git a/terminal.py b/terminal.py
index eafe1ead4a5..4edeaa611dd 100644
--- a/terminal.py
+++ b/terminal.py
@@ -362,7 +362,60 @@ def run_scripts(path: str, test_mode: bool = False):
terminal()
+def main(debug: bool, test: bool, filtert: str, path: List[str]):
+ if test:
+ os.environ["DEBUG_MODE"] = "true"
+
+ if "gst" in path[0]:
+ files = path
+ else:
+ folder = os.path.join(os.path.abspath(os.path.dirname(__file__)), path[0])
+ files = [
+ name
+ for name in os.listdir(folder)
+ if os.path.isfile(os.path.join(folder, name))
+ and name.endswith(".gst")
+ and (filtert in f"{folder}/{name}")
+ ]
+ files.sort()
+ SUCCESSES = 0
+ FAILURES = 0
+ fails = {}
+ length = len(files)
+ i = 0
+ console.print("[green]Gamestonk Terminal Integrated Tests:\n[/green]")
+ for file in files:
+ console.print(f"{file} {((i/length)*100):.1f}%")
+ try:
+ with suppress_stdout():
+ run_scripts(f"{path[0]}/{file}", test_mode=True)
+ SUCCESSES += 1
+ except Exception as e:
+ fails[f"{path[0]}{file}"] = e
+ FAILURES += 1
+ i += 1
+ if fails:
+ console.print("\n[red]Failures:[/red]\n")
+ for key, value in fails.items():
+ console.print(f"{key}: {value}\n")
+ console.print(
+ f"Summary: [green]Successes: {SUCCESSES}[/green] [red]Failures: {FAILURES}[/red]"
+ )
+ else:
+ if debug:
+ os.environ["DEBUG_MODE"] = "true"
+ if isinstance(path, list) and path[0].endswith(".gst"):
+ run_scripts(path[0])
+ elif path:
+ argv_cmds = list([" ".join(path).replace(" /", "/home/")])
+ argv_cmds = insert_start_slash(argv_cmds) if argv_cmds else argv_cmds
+ terminal(argv_cmds)
+ else:
+ terminal()
+
+
if __name__ == "__main__":
+
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="terminal",
@@ -397,7 +450,7 @@ if __name__ == "__main__":
"-f",
"--filter",
help="Send a keyword to filter in file name",
- dest="filter",
+ dest="filtert",
default="",
type=str,
)
@@ -407,54 +460,4 @@ if __name__ == "__main__":
ns_parser = parser.parse_args()
if ns_parser:
- if ns_parser.test:
- os.environ["DEBUG_MODE"] = "true"
-
- if "gst" in ns_parser.path[0]:
- files = ns_parser.path
- else:
- folder = os.path.join(
- os.path.abspath(os.path.dirname(__file__)), ns_parser.path[0]
- )
- files = [
- name
- for name in os.listdir(folder)
- if os.path.isfile(os.path.join(folder, name))
- and name.endswith(".gst")
- and (ns_parser.filter in f"{folder}/{name}")
- ]
- files.sort()
- SUCCESSES = 0
- FAILURES = 0
- fails = {}
- length = len(files)
- i = 0
- console.print("[green]Gamestonk Terminal Integrated Tests:\n[/green]")
- for file in files:
- console.print(f"{file} {((i/length)*100):.1f}%")
- try:
- with suppress_stdout():
- run_scripts(f"{ns_parser.path[0]}/{file}", test_mode=True)
- SUCCESSES += 1
- except Exception as e:
- fails[f"{ns_parser.path[0]}{file}"] = e
- FAILURES += 1
- i += 1
- if fails:
- console.print("\n[red]Failures:[/red]\n")
- for key, value in fails.items():
- console.print(f"{key}: {value}\n")
- console.print(
- f"Summary: [green]Successes: {SUCCESSES}[/green] [red]Failures: {FAILURES}[/red]"
- )
- else:
- if ns_parser.debug:
- os.environ["DEBUG_MODE"] = "true"
- if isinstance(ns_parser.path, list) and ns_parser.path[0].endswith(".gst"):
- run_scripts(ns_parser.path[0])
- elif ns_parser.path:
- argv_cmds = list([" ".join(ns_parser.path).replace(" /", "/home/")])
- argv_cmds = insert_start_slash(argv_cmds) if argv_cmds else argv_cmds
- terminal(argv_cmds)
- else:
- terminal()
+ main(ns_parser.debug, ns_parser.test, ns_parser.filtert, ns_parser.path)
diff --git a/tests/.test_terminal.py.swp b/tests/.test_terminal.py.swp
new file mode 100644
index 00000000000..28f1a787c94
Binary files /dev/null and b/tests/.test_terminal.py.swp differ
diff --git a/tests/gamestonk_terminal/txt/test_menu/test_menu[False-False-None-path1].txt b/tests/gamestonk_terminal/txt/test_menu/test_menu[False-False-None-path1].txt
new file mode 100644
index 00000000000..9e3d967f2a1
--- /dev/null
+++ b/tests/gamestonk_terminal/txt/test_menu/test_menu[False-False-None-path1].txt
@@ -0,0 +1,7 @@
+
+(✨) /alternative/ $ covid
+(✨) /alternative/covid/ $ country Australia
+[cyan]Australia[/cyan] loaded
+
+(✨) /alternative/covid/ $ reset
+resetting...
diff --git a/tests/gamestonk_terminal/txt/test_menu/test_menu[False-True-alt_covid-path2].txt b/tests/gamestonk_terminal/txt/test_menu/test_menu[False-True-alt_covid-path2].txt
new file mode 100644
index 00000000000..4b858482ae4
--- /dev/null
+++ b/tests/gamestonk_terminal/txt/test_menu/test_menu[False-True-alt_covid-path2].txt
@@ -0,0 +1,11 @@
+[green]Gamestonk Terminal Integrated Tests:
+[/green]
+test_alt_covid.gst 0.0%
+
+[red]Failures:[/red]
+
+scripts/test_alt_covid.gst: Can't overwrite existing cassette ('/Users/colindelahunty/Desktop/GamestonkTerminal/tests/gamestonk_terminal/cassettes/test_menu/test_menu[False-True-alt_covid-path2].yaml') in your current record mode ('none').
+No match for the request (