Skip to content
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

Add integration test to download a file by filename #29

Open
pdurbin opened this issue Oct 28, 2015 · 2 comments
Open

Add integration test to download a file by filename #29

pdurbin opened this issue Oct 28, 2015 · 2 comments

Comments

@pdurbin
Copy link
Member

pdurbin commented Oct 28, 2015

I was just looking at IQSS/dataverse#2700 and thinking, "Ideally, how would we have people programmatically download a file of interest?"

I think the answer to this question is for the user to supply the following information:

  • a DOI (or Handle, or generically, a persistent identifier for the dataset)
  • a filename

I was just looking at https://github.com/IQSS/dataverse-client-python/blob/d6e2199f21cddffac37d94d4e39caeaece70ee7e/dataverse/test/test_dataverse.py and I found test where "cat.jpg" is deleted by filename but I couldn't find an example of where a file is downloaded by filename. I think this would be a nice test to have, if it isn't too much trouble to add.

Basically, the DOI of the dataset would be the starting point. Then you enumerate the files in the dataset. Then you find the file that matches "cat.jpg" and download it based on its database id (or some sort of persistent identifier for files, if/when this is implemented as part of IQSS/dataverse#2438 ).

@rliebz
Copy link
Contributor

rliebz commented Oct 28, 2015

Downloading isn't actually a function of the python client. The best it does is provide a download URL based on the file id, and it's up to the consumer of the API to do with that as they will. With the functionality we have, I think that test would be more of a test of the API itself than the python client.

I'm not especially proud of the tests I've put in because they don't do a very good job of distinguishing testing the API vs. the client. Ideally, I think, the tests should cover the internal data structures and consuming the API correctly rather than relying on the test server to behave the way we expect it to.

There's no reason we can't also have integration tests against the server, but it would make sense to keep those separate from the internal tests. So in that respect, I think a test downloading the file wouldn't provide any more information about the state of the python client than would testing that the download url is built the way we expect it to be.

@pdurbin
Copy link
Member Author

pdurbin commented Oct 28, 2015

Ah, I see, you provide a download URL for files here:

self.download_url = '{0}/access/datafile/{1}'.format(
. Thanks.

Very good point about unit vs integration tests. I'll add the word "integration" to the title of this issue. I feel like I'm getting some testing of https://apitest.dataverse.org as a nice byproduct of integration tests. :)

@pdurbin pdurbin changed the title Add test to download a file by filename Add integration test to download a file by filename Oct 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants