File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
simple_repository_browser/tests Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ import json
2
+ import pathlib
3
+
4
+ import pytest
5
+
6
+ import simple_repository_browser
7
+ from simple_repository_browser .static_files import main
8
+
9
+
10
+ def test_cli__help (capsys : pytest .CaptureFixture ) -> None :
11
+ with pytest .raises (SystemExit ) as err_info :
12
+ main (['--help' ])
13
+ assert err_info .value .code == 0
14
+ captured = capsys .readouterr ()
15
+ assert len (captured .out .splitlines ()) > 1
16
+
17
+
18
+ def test_cli__compile (tmp_path : pathlib .Path ) -> None :
19
+ simple_static_dir = pathlib .Path (simple_repository_browser .__file__ ).parent / 'static'
20
+ target_static_dir = tmp_path / 'static'
21
+ orig_files = [
22
+ path for path in simple_static_dir .glob ('**/*' ) if path .is_file () and not path .name .startswith ('.' )
23
+ ]
24
+
25
+ main (['compile' , str (tmp_path / 'static' ), str (simple_static_dir )])
26
+ created_files = [
27
+ path for path in target_static_dir .glob ('**/*' ) if path .is_file () and not path .name .startswith ('.' )
28
+ ]
29
+
30
+ assert len (orig_files ) > 1
31
+ assert len (created_files ) == len (orig_files )
32
+
33
+ manifest_path = target_static_dir / '.manifest.json'
34
+ assert manifest_path .exists ()
35
+
36
+ manifest = json .loads (manifest_path .read_text ())
37
+ file_map = manifest ['file-map' ]
38
+
39
+ assert len (file_map ) == len (orig_files )
You can’t perform that action at this time.
0 commit comments