fake api credentials to write unit tests

66 views
Skip to first unread message

Hédi Chaibi

unread,
Jul 27, 2016, 8:48:05 AM7/27/16
to zotero-dev
Hi,

I am writing a php wrapper for the zotero api.
I want 100% unit tests for the package.

is there a fake/default api credential associated with a library that i can use to write my tests?

Dan Stillman

unread,
Jul 28, 2016, 7:14:51 PM7/28/16
to zoter...@googlegroups.com
On 7/27/16 8:48 AM, Hédi Chaibi wrote:
> I am writing a php wrapper for the zotero api.

Are you aware of libZotero? https://github.com/fcheslack/libZotero

> I want 100% unit tests for the package.
>
> is there a fake/default api credential associated with a library that
> i can use to write my tests?

No, sorry — you'd have to create your own.

But strictly speaking, for unit tests you generally wouldn't touch the
API — you'd mock the HTTP requests. Zotero 5.0, for example, has an
extensive suite of sync-related tests and doesn't make any external HTTP
requests. Otherwise you'd be hitting the API all the time (e.g., on
every commit), which isn't necessary and might get your API key blocked.
You'd also need to deal with existing data in the library, reset it each
time, etc.

Hédi Chaibi

unread,
Jul 29, 2016, 3:01:54 AM7/29/16
to zotero-dev

Yes i have seen fcheslack/libZotero, but there are several things that i do not like in it:

- no documentation (there is indeed html pages in the repo, but it is not a documentation)

- no composer package

- no autoloading (have to require config, build/*, etc…)

- not so convenient ways of calling api methods


Yes, for mocking the api calls in tests, i realized that too. thanks !

Avram Lyon

unread,
Jul 29, 2016, 11:54:46 AM7/29/16
to zotero-dev

One important detail of the existing package is that it is in use on zotero.org and is fully supported- not that you shouldn't try making a new alternative, but improvements to libzotero might get you to what you are looking for with less effort


--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.
To post to this group, send email to zoter...@googlegroups.com.
Visit this group at https://groups.google.com/group/zotero-dev.
For more options, visit https://groups.google.com/d/optout.

fcheslack

unread,
Jul 29, 2016, 12:07:42 PM7/29/16
to zoter...@googlegroups.com
Assuming it's as solid as it already looks I'd actually recommend this
new one at this point.

https://github.com/hedii/zotero-api

The PHP version of libZotero is outdated (living through several API
versions) and is not heavily used on zotero.org anymore (too much
needs to be asynchronous, so it's mostly JS now).

A fresh implementation based on the current API and following more
current PHP standards is great (especially if it also has good test
coverage). Since we've been moving away from PHP it hasn't been a
priority for me though, so thanks for doing this Hédi.

Hédi Chaibi

unread,
Jul 29, 2016, 12:14:59 PM7/29/16
to zotero-dev
https://github.com/hedii/zotero-api 

>>> Lol, this is the package i published few hours ago :)
I am hedii on github

fcheslack

unread,
Jul 29, 2016, 12:17:21 PM7/29/16
to zoter...@googlegroups.com
I know (or at least I assumed). I meant yours looks good and I'd recommend it.

Hédi Chaibi

unread,
Jul 29, 2016, 12:22:11 PM7/29/16
to zotero-dev
ok, i did not understand...
My package is just missing searches parameters and formats methods, but i'll update it as soon as i can.

Avram Lyon

unread,
Jul 29, 2016, 1:11:02 PM7/29/16
to zotero-dev
Well, that shows me for posting with outdated information. :) Glad to see a stronger package coming online!
Reply all
Reply to author
Forward
0 new messages