Skip to content

Commit 2f77c9f

Browse files
committed
Added more test
1 parent 576ca60 commit 2f77c9f

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

ellar_cli/service/cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import sys
55
import typing as t
66

7-
import click
87
from ellar.app import App
98
from ellar.app.context import ApplicationContext
109
from ellar.common.constants import ELLAR_CONFIG_MODULE
@@ -298,7 +297,7 @@ def _import_from_string(self) -> t.Any:
298297
message = (
299298
'Attribute "{attrs_str}" not found in python module "{module_file}".'
300299
)
301-
raise click.ClickException(
300+
raise EllarCLIException(
302301
message.format(attrs_str=attrs_str, module_file=module.__file__)
303302
) from attr_ex
304303
return instance

tests/sample_app/apps/bad_app_3.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/env python
2+
from ellar.app import AppFactory
3+
from ellar.samples import HomeModule
4+
5+
from ellar_cli.main import create_ellar_cli
6+
7+
8+
def bootstrap():
9+
AppFactory.create_app(modules=[HomeModule])
10+
11+
12+
cli = create_ellar_cli("apps.bad_app_3:bootstrap")
13+
14+
if __name__ == "__main__":
15+
cli()

tests/test_ellar_cli_service.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,14 @@ def test_apps_bad_app_2_fails(change_os_dir):
218218
b'Error: Attribute "bootstrap_unknown" not found in python module'
219219
in result.stderr
220220
)
221+
222+
223+
def test_apps_bad_app_3_fails(change_os_dir):
224+
result = subprocess.run(
225+
["python", "apps/bad_app_3.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
226+
)
227+
assert result.returncode == 1
228+
assert (
229+
result.stderr
230+
== b"Error: Boostrap Function must return Instance of `ellar.app.App` type\n"
231+
)

0 commit comments

Comments
 (0)