-
Notifications
You must be signed in to change notification settings - Fork 77
Add origin information to Checkbox JSON submission (new) #1644
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
38d4ea2
Create a function to retrieve version and packaging information
pieqq 1022d86
Use get_origin() to store origin information in submission JSON
pieqq 0d527ad
Switch version 2020-12 of schema (from draft-06)
pieqq 19243ba
Remove client_version and checkbox_version and add origin into the JS…
pieqq 1167327
Refactor Jinja2SessionStateExporter to set origin at init time
pieqq 925fff3
Update unit tests to use the new origin information
pieqq 542cc9c
fix unit test + black formatting issues
pieqq 831c895
Add extra required fields for the packaging section of origin field
pieqq 774f73f
Add "unknown" packaging type if none of the package check worked
pieqq 77efcdc
Handle CalledProcessError as well
pieqq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # This file is part of Checkbox. | ||
| # | ||
| # Copyright 2024 Canonical Ltd. | ||
| # Written by: | ||
| # Pierre Equoy <pierre.equoy@canonical.com> | ||
| # | ||
| # Checkbox is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License version 3, | ||
| # as published by the Free Software Foundation. | ||
| # | ||
| # Checkbox is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| from unittest import TestCase, mock | ||
|
|
||
| import os | ||
| from subprocess import CalledProcessError | ||
|
|
||
| import plainbox | ||
|
|
||
|
|
||
| class PlainboxInitTests(TestCase): | ||
| @mock.patch.dict(os.environ, {"VIRTUAL_ENV": "test"}) | ||
| def test_get_origin_venv(self): | ||
| origin = plainbox.get_origin() | ||
| self.assertEqual(origin["packaging"]["type"], "source") | ||
|
|
||
| @mock.patch.dict(os.environ, {"SNAP_NAME": "test"}) | ||
| def test_get_origin_snap(self): | ||
| origin = plainbox.get_origin() | ||
| self.assertEqual(origin["packaging"]["type"], "snap") | ||
|
|
||
| @mock.patch.dict(os.environ, {}, clear=True) | ||
| @mock.patch("subprocess.check_output") | ||
| def test_get_origin_debian(self, mock_sp_check_output): | ||
| mock_sp_check_output.return_value = ( | ||
| "python3-checkbox-ng: /usr/lib/python3/dist-packages/plainbox\n" | ||
| ) | ||
| origin = plainbox.get_origin() | ||
| self.assertEqual(origin["packaging"]["type"], "debian") | ||
| self.assertEqual(origin["packaging"]["name"], "python3-checkbox-ng") | ||
|
|
||
| @mock.patch.dict(os.environ, {}, clear=True) | ||
| @mock.patch("subprocess.check_output") | ||
| def test_get_origin_exception(self, mock_sp_check_output): | ||
| mock_sp_check_output.side_effect = FileNotFoundError | ||
| origin = plainbox.get_origin() | ||
| self.assertEqual(origin["packaging"]["type"], "unknown") | ||
| mock_sp_check_output.side_effect = CalledProcessError(1, "error") | ||
| origin = plainbox.get_origin() | ||
| self.assertEqual(origin["packaging"]["type"], "unknown") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.