|
26 | 26 | import re |
27 | 27 |
|
28 | 28 |
|
29 | | -# Util function to download library from URL |
30 | | -def download_lib(url, download_dir): |
31 | | - tmp = Path(tempfile.TemporaryDirectory().name) |
32 | | - tmp.mkdir(parents=True, exist_ok=True) |
33 | | - regex = re.compile(r"^(.*)-[0-9]+.[0-9]+.[0-9]") |
34 | | - response = requests.get(url) |
35 | | - # Download and unzips library removing version suffix |
36 | | - with zipfile.ZipFile(io.BytesIO(response.content)) as thezip: |
37 | | - for zipinfo in thezip.infolist(): |
38 | | - with thezip.open(zipinfo) as f: |
39 | | - dest_dir = tmp / regex.sub("\\g<1>", zipinfo.filename) |
40 | | - if zipinfo.is_dir(): |
41 | | - dest_dir.mkdir(parents=True, exist_ok=True) |
42 | | - else: |
43 | | - dest_dir.write_bytes(f.read()) |
44 | | - |
45 | | - # Recreates zip with folder without version suffix |
46 | | - z = zipfile.ZipFile(download_dir, "w") |
47 | | - for f in tmp.glob("**/*"): |
48 | | - z.write(f, arcname=f.relative_to(tmp)) |
49 | | - z.close() |
50 | | - |
51 | | - |
52 | 29 | @pytest.mark.skipif( |
53 | 30 | platform.system() == "Windows", |
54 | 31 | reason="Using a file uri as git url doesn't work on Windows, " |
@@ -77,33 +54,3 @@ def test_install_with_git_url_local_file_uri(run_command, downloads_dir, data_di |
77 | 54 |
|
78 | 55 | # Verifies library is installed |
79 | 56 | assert lib_install_dir.exists() |
80 | | - |
81 | | - |
82 | | -def test_install_with_zip_path_multiple_libraries(run_command, downloads_dir, data_dir): |
83 | | - assert run_command(["update"]) |
84 | | - |
85 | | - env = { |
86 | | - "ARDUINO_DATA_DIR": data_dir, |
87 | | - "ARDUINO_DOWNLOADS_DIR": downloads_dir, |
88 | | - "ARDUINO_SKETCHBOOK_DIR": data_dir, |
89 | | - "ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL": "true", |
90 | | - } |
91 | | - |
92 | | - # Downloads zip to be installed later |
93 | | - wifi_zip_path = Path(downloads_dir, "libraries", "WiFi101-0.16.1.zip") |
94 | | - ble_zip_path = Path(downloads_dir, "libraries", "ArduinoBLE-1.1.3.zip") |
95 | | - download_lib("https://github.com/arduino-libraries/WiFi101/archive/refs/tags/0.16.1.zip", wifi_zip_path) |
96 | | - download_lib("https://github.com/arduino-libraries/ArduinoBLE/archive/refs/tags/1.1.3.zip", ble_zip_path) |
97 | | - |
98 | | - wifi_install_dir = Path(data_dir, "libraries", "WiFi101") |
99 | | - ble_install_dir = Path(data_dir, "libraries", "ArduinoBLE") |
100 | | - |
101 | | - # Verifies libraries are not installed |
102 | | - assert not wifi_install_dir.exists() |
103 | | - assert not ble_install_dir.exists() |
104 | | - |
105 | | - assert run_command(["lib", "install", "--zip-path", wifi_zip_path, ble_zip_path], custom_env=env) |
106 | | - |
107 | | - # Verifies library are installed |
108 | | - assert wifi_install_dir.exists() |
109 | | - assert ble_install_dir.exists() |
0 commit comments