Skip to main content

SENAITE JSON API

Project description

SENAITE JSON API

The JSON API provides a RESTful JSON interface to SENAITE CORE.

SENAITE JSON API v1

Running this test from the buildout directory:

bin/test test_doctests -t JSONAPIv1

Test Setup

Needed Imports:

>>> import transaction

>>> from plone.app.testing import TEST_USER_ID
>>> from plone.app.testing import TEST_USER_PASSWORD

>>> from senaite import api

Functional Helpers:

>>> def start_server():
...     from Testing.ZopeTestCase.utils import startZServer
...     ip, port = startZServer()
...     return "http://{}:{}/{}".format(ip, port, portal.id)

>>> def login(user=TEST_USER_ID, password=TEST_USER_PASSWORD):
...     browser.open(portal_url + "/login_form")
...     browser.getControl(name='__ac_name').value = user
...     browser.getControl(name='__ac_password').value = password
...     browser.getControl(name='submit').click()
...     assert("__ac_password" not in browser.contents)

>>> def logout():
...     browser.open(portal_url + "/logout")
...     assert("You are now logged out" in browser.contents)

Variables:

>>> portal = self.portal
>>> portal_url = portal.absolute_url()
>>> bika_setup = portal.bika_setup
>>> bika_setup_url = portal_url + "/bika_setup"
>>> browser = self.getBrowser()

JSON API:

>>> api_base_url = portal_url + "/@@API/senaite/v1"

Version

Ensure we are logged out:

>>> logout()

The version route should be visible to unauthenticated users:

>>> browser.open(api_base_url + "/version")
>>> browser.contents
'{"url": "http://nohost/plone/@@API/senaite/v1/version", "date": "...", "version": ..., "_runtime": ...}'

Changelog

1.2.0 (2018-01-03)

Added

  • Added parent_path to response data

  • Allow custom methods as attributes in adapter

Removed

Changed

  • Integration to SENAITE CORE

  • License changed to GPLv2

Fixed

  • Fixed Tests

Security

1.1.0 (2017-11-04)

1.0.1 (2017-09-30)

  • Fixed broken release (missing MANIFEST.in)

1.0.0 (2017-09-30)

  • First release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

senaite.jsonapi-1.2.0.zip (54.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page