scriptcast 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scriptcast/__init__.py +0 -0
- scriptcast/__main__.py +371 -0
- scriptcast/assets/__init__.py +0 -0
- scriptcast/assets/fonts/DMSans-Regular.ttf +0 -0
- scriptcast/assets/fonts/Pacifico.ttf +0 -0
- scriptcast/assets/themes/aurora.sh +20 -0
- scriptcast/assets/themes/dark.sh +19 -0
- scriptcast/assets/themes/light.sh +19 -0
- scriptcast/config.py +199 -0
- scriptcast/directives.py +444 -0
- scriptcast/export.py +595 -0
- scriptcast/generator.py +265 -0
- scriptcast/recorder.py +212 -0
- scriptcast/shell/__init__.py +20 -0
- scriptcast/shell/adapter.py +13 -0
- scriptcast/shell/bash.py +11 -0
- scriptcast/shell/zsh.py +11 -0
- scriptcast-0.1.0.dist-info/METADATA +21 -0
- scriptcast-0.1.0.dist-info/RECORD +33 -0
- scriptcast-0.1.0.dist-info/WHEEL +5 -0
- scriptcast-0.1.0.dist-info/entry_points.txt +2 -0
- scriptcast-0.1.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/test_cli.py +304 -0
- tests/test_config.py +400 -0
- tests/test_directives.py +606 -0
- tests/test_export.py +986 -0
- tests/test_generator.py +434 -0
- tests/test_integration.py +97 -0
- tests/test_recorder.py +462 -0
- tests/test_registry.py +57 -0
- tests/test_shell.py +34 -0
- tests/test_theme.py +204 -0
tests/test_theme.py
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# tests/test_theme.py
|
|
2
|
+
"""Tests for theme-related behaviour after theme.py deletion.
|
|
3
|
+
|
|
4
|
+
Theme config is now built via ScriptcastConfig.apply() and ThemeConfig.apply().
|
|
5
|
+
Loading a theme .sh file runs through the recorder pipeline (tested in integration).
|
|
6
|
+
"""
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
# --- ThemeConfig.apply() via ScriptcastConfig ---
|
|
12
|
+
|
|
13
|
+
def test_sc_apply_theme_background():
|
|
14
|
+
from scriptcast.config import ScriptcastConfig
|
|
15
|
+
sc = ScriptcastConfig()
|
|
16
|
+
sc.apply("set", ["theme-background", "1a1a2e,16213e"])
|
|
17
|
+
assert sc.theme.background == "1a1a2e,16213e"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_sc_apply_theme_radius():
|
|
21
|
+
from scriptcast.config import ScriptcastConfig
|
|
22
|
+
sc = ScriptcastConfig()
|
|
23
|
+
sc.apply("set", ["theme-radius", "16"])
|
|
24
|
+
assert sc.theme.radius == 16
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_sc_apply_theme_shadow_false():
|
|
28
|
+
from scriptcast.config import ScriptcastConfig
|
|
29
|
+
sc = ScriptcastConfig()
|
|
30
|
+
sc.apply("set", ["theme-shadow", "false"])
|
|
31
|
+
assert sc.theme.shadow is False
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_sc_apply_theme_margin_one_value():
|
|
35
|
+
from scriptcast.config import ScriptcastConfig
|
|
36
|
+
sc = ScriptcastConfig()
|
|
37
|
+
sc.apply("set", ["theme-margin", "60"])
|
|
38
|
+
assert sc.theme.margin_top == 60
|
|
39
|
+
assert sc.theme.margin_right == 60
|
|
40
|
+
assert sc.theme.margin_bottom == 60
|
|
41
|
+
assert sc.theme.margin_left == 60
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_sc_apply_theme_margin_two_values():
|
|
45
|
+
from scriptcast.config import ScriptcastConfig
|
|
46
|
+
sc = ScriptcastConfig()
|
|
47
|
+
sc.apply("set", ["theme-margin", "82 40"])
|
|
48
|
+
assert sc.theme.margin_top == 82
|
|
49
|
+
assert sc.theme.margin_right == 40
|
|
50
|
+
assert sc.theme.margin_bottom == 82
|
|
51
|
+
assert sc.theme.margin_left == 40
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_sc_apply_theme_margin_three_values():
|
|
55
|
+
from scriptcast.config import ScriptcastConfig
|
|
56
|
+
sc = ScriptcastConfig()
|
|
57
|
+
sc.apply("set", ["theme-margin", "82 82 120"])
|
|
58
|
+
assert sc.theme.margin_top == 82
|
|
59
|
+
assert sc.theme.margin_right == 82
|
|
60
|
+
assert sc.theme.margin_bottom == 120
|
|
61
|
+
assert sc.theme.margin_left == 82
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_sc_apply_theme_margin_individual_side():
|
|
65
|
+
from scriptcast.config import ScriptcastConfig
|
|
66
|
+
sc = ScriptcastConfig()
|
|
67
|
+
sc.apply("set", ["theme-margin-bottom", "120"])
|
|
68
|
+
assert sc.theme.margin_bottom == 120
|
|
69
|
+
assert sc.theme.margin_top is None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_sc_apply_theme_padding_one_value():
|
|
73
|
+
from scriptcast.config import ScriptcastConfig
|
|
74
|
+
sc = ScriptcastConfig()
|
|
75
|
+
sc.apply("set", ["theme-padding", "20"])
|
|
76
|
+
assert sc.theme.padding_top == 20
|
|
77
|
+
assert sc.theme.padding_right == 20
|
|
78
|
+
assert sc.theme.padding_bottom == 20
|
|
79
|
+
assert sc.theme.padding_left == 20
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_sc_apply_theme_padding_two_values():
|
|
83
|
+
from scriptcast.config import ScriptcastConfig
|
|
84
|
+
sc = ScriptcastConfig()
|
|
85
|
+
sc.apply("set", ["theme-padding", "10 20"])
|
|
86
|
+
assert sc.theme.padding_top == 10
|
|
87
|
+
assert sc.theme.padding_right == 20
|
|
88
|
+
assert sc.theme.padding_bottom == 10
|
|
89
|
+
assert sc.theme.padding_left == 20
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_sc_apply_theme_padding_individual_side():
|
|
93
|
+
from scriptcast.config import ScriptcastConfig
|
|
94
|
+
sc = ScriptcastConfig()
|
|
95
|
+
sc.apply("set", ["theme-padding-top", "8"])
|
|
96
|
+
assert sc.theme.padding_top == 8
|
|
97
|
+
assert sc.theme.padding_right == 14 # unchanged default
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_sc_apply_theme_frame_true():
|
|
101
|
+
from scriptcast.config import ScriptcastConfig
|
|
102
|
+
sc = ScriptcastConfig()
|
|
103
|
+
sc.apply("set", ["theme-frame", "true"])
|
|
104
|
+
assert sc.theme.frame is True
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_sc_apply_theme_frame_false():
|
|
108
|
+
from scriptcast.config import ScriptcastConfig
|
|
109
|
+
sc = ScriptcastConfig()
|
|
110
|
+
sc.apply("set", ["theme-frame", "false"])
|
|
111
|
+
assert sc.theme.frame is False
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_sc_apply_terminal_theme():
|
|
115
|
+
from scriptcast.config import ScriptcastConfig
|
|
116
|
+
sc = ScriptcastConfig()
|
|
117
|
+
sc.apply("set", ["terminal-theme", "monokai"])
|
|
118
|
+
assert sc.terminal_theme == "monokai"
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_sc_apply_theme_frame_bar_title():
|
|
122
|
+
from scriptcast.config import ScriptcastConfig
|
|
123
|
+
sc = ScriptcastConfig()
|
|
124
|
+
sc.apply("set", ["theme-frame-bar-title", "Terminal"])
|
|
125
|
+
assert sc.theme.frame_bar_title == "Terminal"
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_sc_apply_theme_scriptcast_watermark_false():
|
|
129
|
+
from scriptcast.config import ScriptcastConfig
|
|
130
|
+
sc = ScriptcastConfig()
|
|
131
|
+
sc.apply("set", ["theme-scriptcast-watermark", "false"])
|
|
132
|
+
assert sc.theme.scriptcast_watermark is False
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# --- CSS shorthand helper (now in config.py) ---
|
|
136
|
+
|
|
137
|
+
def test_parse_css_shorthand_one_value():
|
|
138
|
+
from scriptcast.config import _parse_css_shorthand
|
|
139
|
+
assert _parse_css_shorthand("82") == (82, 82, 82, 82)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def test_parse_css_shorthand_two_values():
|
|
143
|
+
from scriptcast.config import _parse_css_shorthand
|
|
144
|
+
assert _parse_css_shorthand("82 40") == (82, 40, 82, 40)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def test_parse_css_shorthand_three_values():
|
|
148
|
+
from scriptcast.config import _parse_css_shorthand
|
|
149
|
+
assert _parse_css_shorthand("82 40 120") == (82, 40, 120, 40)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_parse_css_shorthand_four_values():
|
|
153
|
+
from scriptcast.config import _parse_css_shorthand
|
|
154
|
+
assert _parse_css_shorthand("82 40 120 60") == (82, 40, 120, 60)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def test_parse_css_shorthand_invalid_raises():
|
|
158
|
+
from scriptcast.config import _parse_css_shorthand
|
|
159
|
+
with pytest.raises(ValueError, match="1-4"):
|
|
160
|
+
_parse_css_shorthand("10 20 30 40 50")
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def test_parse_css_shorthand_multi_value_margin():
|
|
164
|
+
from scriptcast.config import _parse_css_shorthand
|
|
165
|
+
assert _parse_css_shorthand("82 82 120") == (82, 82, 120, 82)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
# --- build_config_from_sc_text: theme keys from .sc ---
|
|
169
|
+
|
|
170
|
+
def test_sc_file_with_theme_directives_builds_theme_config():
|
|
171
|
+
from scriptcast.generator import build_config_from_sc_text
|
|
172
|
+
header = json.dumps({"version": 1, "width": 100, "height": 28, "directive-prefix": "SC"})
|
|
173
|
+
events = [
|
|
174
|
+
json.dumps([0.0, "dir", "set theme-background ff0000,0000ff"]),
|
|
175
|
+
json.dumps([0.1, "dir", "set theme-radius 16"]),
|
|
176
|
+
json.dumps([0.2, "dir", "set terminal-theme light"]),
|
|
177
|
+
]
|
|
178
|
+
sc = header + "\n" + "\n".join(events)
|
|
179
|
+
cfg = build_config_from_sc_text(sc)
|
|
180
|
+
assert cfg.theme.background == "ff0000,0000ff"
|
|
181
|
+
assert cfg.theme.radius == 16
|
|
182
|
+
assert cfg.terminal_theme == "light"
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def test_sc_file_theme_and_script_config():
|
|
186
|
+
from scriptcast.generator import build_config_from_sc_text
|
|
187
|
+
header = json.dumps({"version": 1, "width": 100, "height": 28, "directive-prefix": "SC"})
|
|
188
|
+
events = [
|
|
189
|
+
json.dumps([0.0, "dir", "set type_speed 30"]),
|
|
190
|
+
json.dumps([0.1, "dir", "set theme-frame false"]),
|
|
191
|
+
]
|
|
192
|
+
sc = header + "\n" + "\n".join(events)
|
|
193
|
+
cfg = build_config_from_sc_text(sc)
|
|
194
|
+
assert cfg.type_speed == 30
|
|
195
|
+
assert cfg.theme.frame is False
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def test_sc_file_multi_value_padding():
|
|
199
|
+
from scriptcast.generator import build_config_from_sc_text
|
|
200
|
+
header = json.dumps({"version": 1, "width": 80, "height": 24, "directive-prefix": "SC"})
|
|
201
|
+
sc = header + "\n" + json.dumps([0.0, "dir", "set theme-padding 14 0 0 0"])
|
|
202
|
+
cfg = build_config_from_sc_text(sc)
|
|
203
|
+
assert cfg.theme.padding_top == 14
|
|
204
|
+
assert cfg.theme.padding_right == 0
|