-
Notifications
You must be signed in to change notification settings - Fork 7
Update to workflows to multi-platform testing, latest python #999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
412631c
8cec148
d63cf1f
b0d8c12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "3.23.0" | ||
| __version__ = "3.23.1" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -518,8 +518,7 @@ def _search_by_dataset_file_id(self, | |
|
|
||
| @staticmethod | ||
| def _mime_type(file_path: Path): | ||
| # This string coercion is for supporting pathlib.Path objects in python < 3.8 | ||
| mime_type = mimetypes.guess_type(str(file_path))[0] | ||
| mime_type, _ = mimetypes.guess_type(file_path) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is no longer necessary. |
||
| if mime_type is None: | ||
| mime_type = "application/octet-stream" | ||
| return mime_type | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| from pathlib import Path | ||
| import platform | ||
| from typing import Collection | ||
| from uuid import uuid4, UUID | ||
|
|
||
|
|
@@ -39,19 +40,27 @@ def valid_data() -> dict: | |
| return FileLinkDataFactory(url='www.citrine.io', filename='materials.txt') | ||
|
|
||
|
|
||
| def test_mime_types(collection: FileCollection): | ||
| expected_xlsx = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | ||
| expected_xls = "application/vnd.ms-excel" | ||
| expected_txt = "text/plain" | ||
| expected_unk = "application/octet-stream" | ||
| expected_csv = "text/csv" | ||
|
|
||
| assert collection._mime_type(Path("asdf.xlsx")) == expected_xlsx | ||
| assert collection._mime_type(Path("asdf.XLSX")) == expected_xlsx | ||
| assert collection._mime_type(Path("asdf.xls")) == expected_xls | ||
| assert collection._mime_type(Path("asdf.TXT")) == expected_txt | ||
| assert collection._mime_type(Path("asdf.csv")) == expected_csv | ||
| assert collection._mime_type(Path("asdf.FAKE")) == expected_unk | ||
| @pytest.mark.parametrize( | ||
| ("filename", "mimetype"), | ||
| [ | ||
| pytest.param( | ||
| "asdf.xlsx", | ||
| "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | ||
| marks=pytest.mark.xfail( | ||
| platform.system() == "Windows", | ||
| reason="windows-latest test servers omit xlsx from their registry", | ||
| strict=True | ||
| ) | ||
| ), | ||
| ("asdf.xls", "application/vnd.ms-excel"), | ||
| ("asdf.XLS", "application/vnd.ms-excel"), | ||
| ("asdf.TXT", "text/plain"), | ||
| ("asdf.csv", "text/csv"), | ||
| ("asdf.FAKE", "application/octet-stream"), | ||
| ], | ||
| ) | ||
| def test_mime_types(collection: FileCollection, filename, mimetype): | ||
| assert collection._mime_type(Path(filename)) == mimetype | ||
|
Comment on lines
+43
to
+63
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test now parameterized. The xlsx tests were failing on windows-latest servers because xlsx was not in the build's registry; shouldn't be possible on a Windows box that can open xlsx files.
|
||
|
|
||
|
|
||
| def test_build_equivalence(collection, valid_data): | ||
|
|
@@ -77,9 +86,9 @@ def test_string_representation(valid_data): | |
|
|
||
| def test_from_path(): | ||
| """Test the string representation.""" | ||
| path = '/some/path/with/file.txt' | ||
| path = Path.cwd() / 'some' / 'path' / 'with' / 'file.txt' | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generates a platform-agnostic absolute path, which is what was necessary for the test. |
||
| assert FileLink.from_path(path).filename == 'file.txt' | ||
| assert FileLink.from_path(Path(path)).url == Path(path).as_uri() | ||
| assert FileLink.from_path(str(path)).url == path.as_uri() | ||
| assert FileCollection._is_local_url(FileLink.from_path(path).url) | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.