fastled 1.3.30__py3-none-any.whl → 1.4.50__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.
Files changed (47) hide show
  1. fastled/__init__.py +30 -2
  2. fastled/__main__.py +14 -0
  3. fastled/__version__.py +1 -1
  4. fastled/app.py +51 -2
  5. fastled/args.py +33 -0
  6. fastled/client_server.py +188 -40
  7. fastled/compile_server.py +10 -0
  8. fastled/compile_server_impl.py +34 -1
  9. fastled/docker_manager.py +56 -14
  10. fastled/emoji_util.py +27 -0
  11. fastled/filewatcher.py +6 -3
  12. fastled/find_good_connection.py +105 -0
  13. fastled/header_dump.py +63 -0
  14. fastled/install/__init__.py +1 -0
  15. fastled/install/examples_manager.py +62 -0
  16. fastled/install/extension_manager.py +113 -0
  17. fastled/install/main.py +156 -0
  18. fastled/install/project_detection.py +167 -0
  19. fastled/install/test_install.py +373 -0
  20. fastled/install/vscode_config.py +344 -0
  21. fastled/interruptible_http.py +148 -0
  22. fastled/live_client.py +21 -1
  23. fastled/open_browser.py +84 -16
  24. fastled/parse_args.py +110 -9
  25. fastled/playwright/chrome_extension_downloader.py +207 -0
  26. fastled/playwright/playwright_browser.py +773 -0
  27. fastled/playwright/resize_tracking.py +127 -0
  28. fastled/print_filter.py +52 -52
  29. fastled/project_init.py +20 -13
  30. fastled/select_sketch_directory.py +142 -19
  31. fastled/server_flask.py +37 -1
  32. fastled/settings.py +47 -3
  33. fastled/sketch.py +121 -4
  34. fastled/string_diff.py +162 -26
  35. fastled/test/examples.py +7 -5
  36. fastled/types.py +4 -0
  37. fastled/util.py +34 -0
  38. fastled/version.py +41 -41
  39. fastled/web_compile.py +379 -236
  40. fastled/zip_files.py +76 -0
  41. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/METADATA +533 -508
  42. fastled-1.4.50.dist-info/RECORD +60 -0
  43. fastled-1.3.30.dist-info/RECORD +0 -44
  44. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/WHEEL +0 -0
  45. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/entry_points.txt +0 -0
  46. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/licenses/LICENSE +0 -0
  47. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,373 @@
1
+ """Comprehensive test suite for FastLED install feature."""
2
+
3
+ import json
4
+ import os
5
+ import shutil
6
+ import sys
7
+ import tempfile
8
+ import unittest
9
+ from pathlib import Path
10
+ from unittest.mock import MagicMock, patch
11
+
12
+ # Add parent directory to path for imports
13
+ sys.path.insert(0, str(Path(__file__).parent.parent.parent))
14
+
15
+ from fastled.install.main import auto_execute_fastled, fastled_install
16
+ from fastled.install.project_detection import (
17
+ check_existing_arduino_content,
18
+ )
19
+ from fastled.install.vscode_config import (
20
+ generate_fastled_tasks,
21
+ update_launch_json_for_arduino,
22
+ update_vscode_settings_for_fastled,
23
+ )
24
+
25
+
26
+ class TestFastLEDInstall(unittest.TestCase):
27
+ """Test FastLED installation functionality."""
28
+
29
+ def setUp(self):
30
+ """Set up test environment."""
31
+ self.test_dir = tempfile.mkdtemp()
32
+ self.original_cwd = os.getcwd()
33
+ os.chdir(self.test_dir)
34
+
35
+ def tearDown(self):
36
+ """Clean up test environment."""
37
+ os.chdir(self.original_cwd)
38
+ shutil.rmtree(self.test_dir)
39
+
40
+ @patch("fastled.install.project_detection.shutil.which")
41
+ @patch("builtins.input")
42
+ def test_dry_run_basic_project(self, mock_input, mock_which):
43
+ """Test 1: Dry-run in basic project."""
44
+ # Setup
45
+ mock_which.return_value = "/usr/bin/code"
46
+ mock_input.return_value = "y"
47
+ os.makedirs(".vscode")
48
+
49
+ # Run
50
+ result = fastled_install(dry_run=True, no_interactive=True)
51
+
52
+ # Verify
53
+ self.assertTrue(result)
54
+ self.assertTrue(Path(".vscode/launch.json").exists())
55
+ self.assertTrue(Path(".vscode/tasks.json").exists())
56
+
57
+ @patch("fastled.install.project_detection.is_fastled_repository")
58
+ @patch("fastled.install.project_detection.detect_fastled_project")
59
+ @patch("fastled.install.project_detection.shutil.which")
60
+ @patch("builtins.input")
61
+ def test_dry_run_fastled_external(
62
+ self, mock_input, mock_which, mock_detect, mock_repo
63
+ ):
64
+ """Test 2: Dry-run in external FastLED project."""
65
+ # Setup
66
+ mock_which.return_value = "/usr/bin/code"
67
+ mock_input.return_value = "y"
68
+ mock_detect.return_value = True
69
+ mock_repo.return_value = False
70
+ os.makedirs(".vscode")
71
+
72
+ # Create library.json
73
+ with open("library.json", "w") as f:
74
+ json.dump({"name": "FastLED"}, f)
75
+
76
+ # Run
77
+ result = fastled_install(dry_run=True, no_interactive=True)
78
+
79
+ # Verify
80
+ self.assertTrue(result)
81
+ self.assertFalse(Path(".vscode/settings.json").exists()) # No clangd settings
82
+
83
+ @patch("fastled.install.project_detection.is_fastled_repository")
84
+ @patch("fastled.install.project_detection.detect_fastled_project")
85
+ @patch("fastled.install.project_detection.shutil.which")
86
+ @patch("builtins.input")
87
+ def test_dry_run_fastled_repository(
88
+ self, mock_input, mock_which, mock_detect, mock_repo
89
+ ):
90
+ """Test 3: Dry-run in actual FastLED repository."""
91
+ # Setup
92
+ mock_which.return_value = "/usr/bin/code"
93
+ mock_input.return_value = "y"
94
+ mock_detect.return_value = True
95
+ mock_repo.return_value = True
96
+ os.makedirs(".vscode")
97
+
98
+ # Run
99
+ result = fastled_install(dry_run=True, no_interactive=True)
100
+
101
+ # Verify
102
+ self.assertTrue(result)
103
+ self.assertTrue(Path(".vscode/settings.json").exists()) # Has clangd settings
104
+
105
+ @patch("fastled.install.project_detection.shutil.which")
106
+ @patch("builtins.input")
107
+ def test_existing_vscode_project(self, mock_input, mock_which):
108
+ """Test 4: Merge with existing .vscode configs."""
109
+ # Setup
110
+ mock_which.return_value = "/usr/bin/code"
111
+ mock_input.return_value = "y"
112
+ os.makedirs(".vscode")
113
+
114
+ # Create existing launch.json
115
+ existing_config = {
116
+ "version": "0.2.0",
117
+ "configurations": [{"name": "Existing", "type": "node"}],
118
+ }
119
+ with open(".vscode/launch.json", "w") as f:
120
+ json.dump(existing_config, f)
121
+
122
+ # Run
123
+ result = fastled_install(dry_run=True, no_interactive=True)
124
+
125
+ # Verify
126
+ self.assertTrue(result)
127
+ with open(".vscode/launch.json") as f:
128
+ data = json.load(f)
129
+ self.assertEqual(len(data["configurations"]), 2)
130
+ self.assertEqual(
131
+ data["configurations"][0]["name"],
132
+ "🎯 Auto Debug (Smart File Detection)",
133
+ )
134
+
135
+ @patch("fastled.install.project_detection.shutil.which")
136
+ @patch("builtins.input")
137
+ def test_parent_directory_detection(self, mock_input, mock_which):
138
+ """Test 5: Find .vscode in parent directories."""
139
+ # Setup
140
+ mock_which.return_value = "/usr/bin/code"
141
+ parent_dir = Path(self.test_dir)
142
+ child_dir = parent_dir / "child" / "grandchild"
143
+ child_dir.mkdir(parents=True)
144
+ (parent_dir / ".vscode").mkdir()
145
+ os.chdir(child_dir)
146
+
147
+ # Test non-interactive mode - should fail
148
+ result = fastled_install(dry_run=True, no_interactive=True)
149
+ self.assertFalse(result) # Should fail in non-interactive
150
+
151
+ # Test interactive mode
152
+ mock_input.side_effect = ["y", "y"] # Yes to parent, yes to extension
153
+ result = fastled_install(dry_run=True, no_interactive=False)
154
+
155
+ # Verify - we should be in parent directory now
156
+ self.assertTrue(result)
157
+ self.assertEqual(Path.cwd(), parent_dir)
158
+
159
+ @patch("fastled.install.project_detection.shutil.which")
160
+ @patch("builtins.input")
161
+ def test_project_generation(self, mock_input, mock_which):
162
+ """Test 6: Generate new VSCode project."""
163
+ # Setup
164
+ mock_which.return_value = "/usr/bin/code"
165
+
166
+ # Test non-interactive mode - should fail
167
+ result = fastled_install(dry_run=True, no_interactive=True)
168
+ self.assertFalse(result) # Should fail without .vscode
169
+
170
+ # Test interactive mode
171
+ mock_input.side_effect = ["y", "y"] # Yes to generate, yes to extension
172
+ result = fastled_install(dry_run=True, no_interactive=False)
173
+
174
+ # Verify
175
+ self.assertTrue(result)
176
+ self.assertTrue(Path(".vscode").exists())
177
+ self.assertTrue(Path(".vscode/launch.json").exists())
178
+ self.assertTrue(Path(".vscode/tasks.json").exists())
179
+
180
+ def test_arduino_content_detection(self):
181
+ """Test 7: Detect existing .ino files."""
182
+ # Create .ino file
183
+ with open("test.ino", "w") as f:
184
+ f.write("void setup() {}")
185
+
186
+ # Test detection
187
+ self.assertTrue(check_existing_arduino_content())
188
+
189
+ # Remove and test examples folder
190
+ os.unlink("test.ino")
191
+ os.makedirs("examples")
192
+ self.assertTrue(check_existing_arduino_content())
193
+
194
+ @patch("fastled.install.project_detection.shutil.which")
195
+ @patch("builtins.input")
196
+ def test_tasks_json_merging(self, mock_input, mock_which):
197
+ """Test 8: Merge FastLED tasks with existing."""
198
+ # Setup
199
+ mock_which.return_value = "/usr/bin/code"
200
+ mock_input.return_value = "y"
201
+ os.makedirs(".vscode")
202
+
203
+ # Create existing tasks.json
204
+ existing_tasks = {
205
+ "version": "2.0.0",
206
+ "tasks": [{"label": "Existing Task", "command": "echo"}],
207
+ }
208
+ with open(".vscode/tasks.json", "w") as f:
209
+ json.dump(existing_tasks, f)
210
+
211
+ # Run
212
+ generate_fastled_tasks()
213
+
214
+ # Verify
215
+ with open(".vscode/tasks.json") as f:
216
+ data = json.load(f)
217
+ self.assertEqual(len(data["tasks"]), 3) # 1 existing + 2 FastLED
218
+ labels = [task["label"] for task in data["tasks"]]
219
+ self.assertIn("Run FastLED (Debug)", labels)
220
+ self.assertIn("Run FastLED (Quick)", labels)
221
+
222
+ def test_launch_json_updates(self):
223
+ """Test 9: Update launch.json configurations."""
224
+ # Setup
225
+ os.makedirs(".vscode")
226
+
227
+ # Run
228
+ update_launch_json_for_arduino()
229
+
230
+ # Verify
231
+ with open(".vscode/launch.json") as f:
232
+ data = json.load(f)
233
+ self.assertEqual(len(data["configurations"]), 1)
234
+ config = data["configurations"][0]
235
+ self.assertEqual(config["name"], "🎯 Auto Debug (Smart File Detection)")
236
+ self.assertEqual(config["type"], "auto-debug")
237
+ self.assertIn("*.ino", config["map"])
238
+
239
+ @patch("fastled.install.project_detection.is_fastled_repository")
240
+ def test_safety_clangd_protection(self, mock_repo):
241
+ """Test 10: 🚨 CRITICAL - clangd safety protection."""
242
+ # Setup
243
+ os.makedirs(".vscode")
244
+
245
+ # Test non-repository
246
+ mock_repo.return_value = False
247
+ update_vscode_settings_for_fastled()
248
+ self.assertFalse(Path(".vscode/settings.json").exists())
249
+
250
+ # Test repository
251
+ mock_repo.return_value = True
252
+ update_vscode_settings_for_fastled()
253
+ self.assertTrue(Path(".vscode/settings.json").exists())
254
+
255
+ with open(".vscode/settings.json") as f:
256
+ data = json.load(f)
257
+ self.assertIn("clangd.arguments", data)
258
+
259
+ @patch("fastled.install.main.check_existing_arduino_content")
260
+ def test_auto_execution_trigger(self, mock_check):
261
+ """Test 11: Post-installation auto-execution."""
262
+ # Setup
263
+ mock_check.return_value = True
264
+ original_argv = sys.argv.copy()
265
+ sys.argv = ["fastled", "--install"]
266
+
267
+ try:
268
+ # We'll test that auto_execute_fastled modifies sys.argv correctly
269
+ # without actually calling main()
270
+ with patch("fastled.app.main") as mock_main:
271
+ mock_main.return_value = 0
272
+ auto_execute_fastled()
273
+
274
+ # Verify
275
+ mock_main.assert_called_once()
276
+ # Check that argv was filtered before calling main
277
+ # The function should have set sys.argv to ['fastled', '.']
278
+ finally:
279
+ sys.argv = original_argv
280
+
281
+ @patch("fastled.install.project_detection.shutil.which")
282
+ def test_no_ide_error_handling(self, mock_which):
283
+ """Test 12: Error when no IDE available."""
284
+ # Setup
285
+ mock_which.return_value = None
286
+
287
+ # Run
288
+ from fastled.install.project_detection import validate_vscode_project
289
+
290
+ result = validate_vscode_project(no_interactive=True)
291
+
292
+ # Verify
293
+ self.assertFalse(result)
294
+
295
+ @patch("subprocess.run")
296
+ @patch("builtins.input")
297
+ def test_examples_installation(self, mock_input, mock_run):
298
+ """Test 13: --project-init examples installation."""
299
+ # Setup
300
+ mock_input.return_value = "y"
301
+ mock_run.return_value = MagicMock(returncode=0)
302
+
303
+ # Run
304
+ from fastled.install.examples_manager import (
305
+ install_fastled_examples_via_project_init,
306
+ )
307
+
308
+ # Test non-interactive mode - should skip
309
+ result = install_fastled_examples_via_project_init(no_interactive=True)
310
+ self.assertFalse(result)
311
+
312
+ # Test interactive mode
313
+ result = install_fastled_examples_via_project_init(no_interactive=False)
314
+ self.assertTrue(result)
315
+ mock_run.assert_called_once()
316
+ call_args = mock_run.call_args[0][0]
317
+ self.assertEqual(call_args, ["fastled", "--project-init"])
318
+
319
+ @patch("fastled.install.extension_manager.download_auto_debug_extension")
320
+ @patch("fastled.install.extension_manager.install_vscode_extensions")
321
+ def test_extension_installation_flow(self, mock_install, mock_download):
322
+ """Test 14: Auto Debug extension prompt/install."""
323
+ # Setup
324
+ mock_download.return_value = Path("test.vsix")
325
+ mock_install.return_value = True
326
+
327
+ # Test dry run
328
+ from fastled.install.extension_manager import install_auto_debug_extension
329
+
330
+ result = install_auto_debug_extension(dry_run=True)
331
+ self.assertTrue(result)
332
+ mock_download.assert_not_called()
333
+
334
+ # Test real install
335
+ result = install_auto_debug_extension(dry_run=False)
336
+ self.assertTrue(result)
337
+ mock_download.assert_called_once()
338
+ mock_install.assert_called_once()
339
+
340
+ @patch("fastled.install.project_detection.is_fastled_repository")
341
+ @patch("fastled.install.project_detection.shutil.which")
342
+ @patch("builtins.input")
343
+ def test_comprehensive_integration(self, mock_input, mock_which, mock_repo):
344
+ """Test 15: End-to-end integration test."""
345
+ # Setup
346
+ mock_which.return_value = "/usr/bin/code"
347
+ mock_input.side_effect = ["y", "y", "y"] # Yes to project, extension, examples
348
+ mock_repo.return_value = False
349
+
350
+ # Create .vscode first for non-interactive test
351
+ os.makedirs(".vscode")
352
+
353
+ # Run full installation in non-interactive mode
354
+ result = fastled_install(dry_run=True, no_interactive=True)
355
+
356
+ # Verify all components
357
+ self.assertTrue(result)
358
+ self.assertTrue(Path(".vscode").exists())
359
+ self.assertTrue(Path(".vscode/launch.json").exists())
360
+ self.assertTrue(Path(".vscode/tasks.json").exists())
361
+
362
+ # Verify tasks have correct content
363
+ with open(".vscode/tasks.json") as f:
364
+ data = json.load(f)
365
+ debug_task = next(
366
+ t for t in data["tasks"] if t["label"] == "Run FastLED (Debug)"
367
+ )
368
+ self.assertIn("--debug", debug_task["args"])
369
+ self.assertIn("--app", debug_task["args"])
370
+
371
+
372
+ if __name__ == "__main__":
373
+ unittest.main()