Skip to content

Commit

Permalink
doctor: fix errors when there is no config (thumbor#1397)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelometal authored Jan 26, 2022
1 parent 5dcb28c commit 63c9f9f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
39 changes: 39 additions & 0 deletions tests/snapshots/snap_test_doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,42 @@
Don't forget to copy this log and add it to the description.
Open an issue at https://github.com/thumbor/thumbor/issues/new
'''

snapshots['test_get_doctor_output_no_config 1'] = '''
Thumbor doctor will analyze your install and verify if everything is working as expected.
Verifying libraries support...
✅ pycurl is installed correctly.
✅ cairosvg is installed correctly.
✅ cv2 is installed correctly.
Verifying thumbor compiled extensions...
✅ _alpha
✅ _bounding_box
✅ _brightness
✅ _colorize
✅ _composite
✅ _contrast
✅ _convolution
✅ _curve
✅ _equalize
✅ _fill
✅ _nine_patch
✅ _noise
✅ _rgb
✅ _round_corner
✅ _saturation
✅ _sharpen
Verifying extension programs...
✅ jpegtran is installed correctly.
✅ ffmpeg is installed correctly.
✅ gifsicle is installed correctly.
Verifying security...
🎉 Congratulations! No errors found! 🎉
'''
14 changes: 14 additions & 0 deletions tests/test_doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,17 @@ def test_get_doctor_output(snapshot, capsys):
)
result = capsys.readouterr()
snapshot.assert_match(result.out)


def test_get_doctor_output_no_config(snapshot, capsys):
run_doctor(
{
"nocolor": True,
"config": None,
},
print_version=False,
exit_with_error=False,
check_pyexiv=False,
)
result = capsys.readouterr()
snapshot.assert_match(result.out)
6 changes: 4 additions & 2 deletions thumbor/doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def newline():

def check_extensibility_modules(cfg):
if cfg is None:
return None
return []

newline()
errors = []
Expand Down Expand Up @@ -318,6 +318,9 @@ def check_security(cfg):
errors = []
warnings = []

if cfg is None:
return errors, warnings

if cfg.SECURITY_KEY == "MY_SECURE_KEY":
print(cf.bold_red(f"{CROSS} Using default security key."))

Expand Down Expand Up @@ -393,7 +396,6 @@ def check_everything(cfg, check_pyexiv):
def print_results(warnings, errors):
if not warnings and not errors:
print(cf.bold_green("🎉 Congratulations! No errors found! 🎉"))
sys.exit(1)
return

print(cf.bold_red("😞 Oh no! We found some things that could improve... 😞"))
Expand Down

0 comments on commit 63c9f9f

Please sign in to comment.