# Test download predicate parsing?

**URL:** <https://discourse.gbif.org/t/test-download-predicate-parsing/1701>\
**Category:** Miscellaneous\
**Created:** [February 3, 2020, 7:22pm UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701 "2020-02-03T19:22:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sckott](https://sea1.discourse-cdn.com/gbif1/user_avatar/discourse.gbif.org/sckott/32/122_2.png) [@sckott](https://discourse.gbif.org/u/sckott)\
**Post date:** [February 3, 2020, 7:22pm UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/1 "2020-02-03T19:22:10Z")

</div>

I don’t currently have unit tests in `rgbif` to determine if download predicates built by users will actually work. I could kick off actual downloads in tests, but that doesn’t seem like a good idea to hit the download service in tests.

Is there an API end point for testing download predicates that does not kick off downloads? That is, I want to test that download requests coming from `rgbif` are formatted correctly and parsed successfully by GBIF, but not kick off real downloads.

---

<div class="post-metadata">

**Author:** ![dnoesgaard](https://sea1.discourse-cdn.com/gbif1/user_avatar/discourse.gbif.org/dnoesgaard/32/8_2.png) [@dnoesgaard](https://discourse.gbif.org/u/dnoesgaard)\
**Post date:** [February 4, 2020, 8:23am UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/2 "2020-02-04T08:23:34Z")

</div>

I’m not aware of such a service, but I think it’s good idea. Perhaps a simple flag in the request, e.g.

´´´

```auto
{
  "creator": "userName",
  "notificationAddresses": [
    "userEmail@example.org"
  ],
  "sendNotification": true,
  "format": "SIMPLE_CSV",
  "test": true,
  "predicate": {
...

```

and then return 201 if successful? I guess it might also be set in the header to test the validity of the entire payload.

@MattBlissett, any comments or thoughts?

---

<div class="post-metadata">

**Author:** ![MattBlissett](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MattBlissett](https://discourse.gbif.org/u/MattBlissett)\
**Post date:** [February 4, 2020, 10:11am UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/3 "2020-02-04T10:11:42Z")

</div>

There’s nothing at the moment, maybe we should add something.

You can use [api.gbif-uat.org](http://api.gbif-uat.org) for tests, which at least avoids creating real DOIs for each download. With an HTTP DELETE request, a download can be cancelled. This would be necessary after each test, as there’s a maximum of three concurrent downloads per user.

---

<div class="post-metadata">

**Author:** ![sckott](https://sea1.discourse-cdn.com/gbif1/user_avatar/discourse.gbif.org/sckott/32/122_2.png) [@sckott](https://discourse.gbif.org/u/sckott)\
**Post date:** [February 4, 2020, 4:54pm UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/4 "2020-02-04T16:54:03Z")

</div>

Thanks @dnoesgaard - that’s a good idea to have a boolean to toggle

Thanks for that idea @MattBlissett - I’ll probably try that, using `api.gbif-uat.org`. And good idea to delete them after testing. I need to fix something in my vcr package, which should be done soon, then I can cache test fixtures for these tests. But definitely should remake them often in case you all change things on your side in terms of how queries are parsed.

Is `api.gbif-uat.org` exactly the same setup as `api.gbif.org` ?

---

<div class="post-metadata">

**Author:** ![MattBlissett](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MattBlissett](https://discourse.gbif.org/u/MattBlissett)\
**Post date:** [February 4, 2020, 6:59pm UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/5 "2020-02-04T18:59:32Z")

</div>

[api.gbif-uat.org](http://api.gbif-uat.org) is supposed to be the same as [api.gbif.org](http://api.gbif.org), although on occasion we may run our own testing – in that case, pieces can be broken or running the next version of a GBIF service.

Downloads use parts of the occurrence API and the registry, and it’s unusual that these would be unavailable on UAT.

---

<div class="post-metadata">

**Author:** ![sckott](https://sea1.discourse-cdn.com/gbif1/user_avatar/discourse.gbif.org/sckott/32/122_2.png) [@sckott](https://discourse.gbif.org/u/sckott)\
**Post date:** [February 4, 2020, 7:16pm UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/6 "2020-02-04T19:16:31Z")

</div>

Thanks, will report back if I run into any issues

---

<div class="post-metadata">

**Author:** ![sckott](https://sea1.discourse-cdn.com/gbif1/user_avatar/discourse.gbif.org/sckott/32/122_2.png) [@sckott](https://discourse.gbif.org/u/sckott)\
**Post date:** [February 14, 2020, 11:58pm UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/7 "2020-02-14T23:58:25Z")

</div>

@MattBlissett Thinking about this some more, should unit tests for pygbif and rgbif in general (for all their unit tests) use `api.gbif-uat.org` instead of `api.gbif.org` ? or do you think it’s a good idea to test against what users are actually using?

---

<div class="post-metadata">

**Author:** ![MattBlissett](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MattBlissett](https://discourse.gbif.org/u/MattBlissett)\
**Post date:** [February 19, 2020, 5:00pm UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/8 "2020-02-19T17:00:26Z")

</div>

[api.gbif-uat.org](http://api.gbif-uat.org) generally uses the same software versions as [api.gbif.org](http://api.gbif.org), so should be used for all testing that would make changes – e.g. creating downloads. The system is smaller, and has fewer occurrence records, and can be slower.

Sometimes, UAT will be running a slightly newer version, but in that case it’s likely that we plan to run it in production soon.

---

<div class="post-metadata">

**Author:** ![sckott](https://sea1.discourse-cdn.com/gbif1/user_avatar/discourse.gbif.org/sckott/32/122_2.png) [@sckott](https://discourse.gbif.org/u/sckott)\
**Post date:** [February 19, 2020, 5:58pm UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/9 "2020-02-19T17:58:55Z")

</div>

thanks @MattBlissett

Sounds like you’re suggesting I use uat for downloads testing, but that I stick with `api.gbif.org` for all other testing.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/gbif1/original/1X/d2525d53d815eb0c992cc44730ed8a6a1be1dbb5.png) [@system](https://discourse.gbif.org/u/system)\
**Post date:** [March 21, 2020, 3:58am UTC](https://discourse.gbif.org/t/test-download-predicate-parsing/1701/10 "2020-03-21T03:58:57Z")

</div>

Closed on March 21, 2020, 3:58am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
