-
Notifications
You must be signed in to change notification settings - Fork 124
Add support for export and import commands #593
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
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 |
|---|---|---|
|
|
@@ -137,6 +137,28 @@ def test_prune(self, mock): | |
| actual, {"VolumesDeleted": ["dbase", "source"], "SpaceReclaimed": 2048} | ||
| ) | ||
|
|
||
| @requests_mock.Mocker() | ||
| def test_import(self, mock): | ||
| mock.post( | ||
| tests.LIBPOD_URL + "/volumes/dbase/import", | ||
| status_code=requests.codes.no_content, | ||
| ) | ||
| actual = self.client.volumes.import_archive("dbase", data=b'mocked_archive') | ||
| self.assertIsInstance(actual, type(None)) | ||
|
|
||
| with self.assertRaises(RuntimeError): | ||
| # The archive does not exist | ||
| self.client.volumes.import_archive("dbase", path="/path/to/archive.tar") | ||
|
|
||
| @requests_mock.Mocker() | ||
| def test_export(self, mock): | ||
| mock.get( | ||
| tests.LIBPOD_URL + "/volumes/dbase/export", | ||
| content=b'exported_archive', | ||
| ) | ||
| actual = self.client.volumes.export_archive("dbase") | ||
| self.assertIsInstance(actual, bytes) | ||
|
Contributor
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. To be honest, I'm not sure about the value of these mock tests (for the import and export). I wouldn't have added them if you didn't ask for it.
Contributor
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. My motivation is primarily code coverage. In addition to this, tests help me a lot with future features working with the community, even when they are simple. I'd like to hear your opinion: why you are not sure of the value for these specific tests. Do you mean they are too trivial? thanks a lot for the patience and for updating the pr
Contributor
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. I was mainly talking about the functions I added. There isn't much to test without an actual volume and archive file. But don't get me wrong, I think mock tests in general are great to add more test coverage in particular for complex scenario that are not easy to reproduce in actual integration test.
Contributor
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. I think it would be very nice to do something like this in python, but we are missing other options in the python bindings to do so podman volume create testvol
podman volume export testvol --output testvol.tar
mkdir testvol
tar -xvf testvol.tar -C testvol/
touch testvol/test
tar -rf testvol.tar testvol/test
cat testvol.tar | podman volume import testvol -
podman unshare
podman volume mount testvol
ls /home/nsella/.local/share/containers/storage/volumes/testvol/_data/testvol/testSo I think your tests are now good |
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
Uh oh!
There was an error while loading. Please reload this page.