1
+ import pytest
1
2
from click .testing import CliRunner
2
3
3
4
from brainglobe_atlasapi import cli , config
@@ -22,10 +23,12 @@ def test_config_cli():
22
23
23
24
24
25
def test_update_command ():
25
- runner = CliRunner ()
26
-
27
- # Test printing of config file:
28
- runner .invoke (cli .bg_cli , ["config" , "-a" , "example_mouse_100um" , "-f" ])
26
+ """Test update command."""
27
+ update_atlas = CliRunner ().invoke (
28
+ cli .bg_cli , ["update" , "-a" , "example_mouse_100um" , "-f" ]
29
+ )
30
+ expected_output = "updating example_mouse_100um\n Downloading..."
31
+ assert expected_output in update_atlas .output
29
32
30
33
31
34
def test_install_command ():
@@ -35,8 +38,35 @@ def test_install_command():
35
38
runner .invoke (cli .bg_cli , ["install" , "-a" , "example_mouse_100um" ])
36
39
37
40
38
- def test_list_command ():
39
- runner = CliRunner ()
41
+ def test_cli_list ():
42
+ """Test list command."""
43
+ atlases_table = CliRunner ().invoke (cli .bg_cli , ["list" , "--show" ])
44
+ assert atlases_table .exit_code == 0
45
+ assert "nadkarni_mri_mouselemur_91um" in atlases_table .output
40
46
41
- # Test printing of config file:
42
- runner .invoke (cli .bg_cli , ["list" , "s" ])
47
+
48
+ @pytest .mark .parametrize (
49
+ ["command" ], [pytest .param ("install" ), pytest .param ("update" )]
50
+ )
51
+ def test_atlas_name_is_none_value_error (command ):
52
+ """Test whether command without atlas name raises ValueError."""
53
+ with pytest .raises (
54
+ ValueError ,
55
+ match = (
56
+ f'No atlas named passed with command "{ command } ". Use the "-a"'
57
+ r"\s+argument to pass an atlas name"
58
+ ),
59
+ ):
60
+ CliRunner ().invoke (
61
+ cli .bg_cli , [command , "-a" , None ], catch_exceptions = False
62
+ )
63
+
64
+
65
+ def test_cli_incorrect_command ():
66
+ """Test whether incorrect "flibble" command raises ValueError."""
67
+ command = "flibble"
68
+ with pytest .raises (
69
+ ValueError ,
70
+ match = f'Invalid command { command } . use "brainglobe -h for more info."' ,
71
+ ):
72
+ CliRunner ().invoke (cli .bg_cli , [command ], catch_exceptions = False )
0 commit comments