Skip to content

Commit

Permalink
Renamed OpenPhoto to Trovebox
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakypete81 committed Jul 19, 2013
1 parent 57b593d commit 6f70330
Show file tree
Hide file tree
Showing 30 changed files with 368 additions and 365 deletions.
49 changes: 25 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,35 @@ OpenPhoto/Trovebox Python Library
:alt: Build Status
:target: https://travis-ci.org/photo/openphoto-python

.. image:: https://pypip.in/v/openphoto/badge.png
.. image:: https://pypip.in/v/trovebox/badge.png
:alt: Python Package Index (PyPI)
:target: https://pypi.python.org/pypi/openphoto
:target: https://pypi.python.org/pypi/trovebox

This library works with any `OpenPhoto <https://github.com/photo>`__ server
(including the `Trovebox <http://trovebox.com>`__ hosted service).
This library works with any Trovebox server, either
`Self-hosted <https://github.com/photo>`__, or using the
`Trovebox hosted service<http://trovebox.com>`__).
It provides full access to your photos and metadata, via a simple
Pythonic API.

Installation
============
::

pip install openphoto
pip install trovebox

Documentation
=============
See the `OpenPhoto/Trovebox API Documentation <https://trovebox.com/documentation>`__
See the `Trovebox API Documentation <https://trovebox.com/documentation>`__
for full API documentation, including Python examples.

All development takes place at the `openphoto-python GitHub site <https://github.com/photo/openphoto-python>`__.

Credentials
===========
For full access to your photos, you need to create the following config
file in ``~/.config/openphoto/default``::
file in ``~/.config/trovebox/default``::

# ~/.config/openphoto/default
# ~/.config/trovebox/default
host = your.host.com
consumerKey = your_consumer_key
consumerSecret = your_consumer_secret
Expand All @@ -52,14 +53,14 @@ Using the library
=================
::

from openphoto import OpenPhoto
client = OpenPhoto()
from trovebox import Trovebox
client = Trovebox()
photos = client.photos.list()
photos[0].update(tags=["tag1", "tag2"])
print(photos[0].tags)

The OpenPhoto Python class hierarchy mirrors the
`OpenPhoto/Trovebox API <https://trovebox.com/documentation>`__ endpoint layout.
The Trovebox Python class hierarchy mirrors the
`Trovebox API <https://trovebox.com/documentation>`__ endpoint layout.
For example, the calls in the example above use the following API endpoints:

* ``client.photos.list() -> /photos/list.json``
Expand All @@ -72,22 +73,22 @@ You can also access the API at a lower level using GET/POST methods::

API Versioning
==============
It may be useful to lock your application to a particular version of the OpenPhoto API.
It may be useful to lock your application to a particular version of the Trovebox API.
This ensures that future API updates won't cause unexpected breakages.

To do this, add the optional ``api_version`` parameter when creating the client object::

from openphoto import OpenPhoto
client = OpenPhoto(api_version=2)
from trovebox import Trovebox
client = Trovebox(api_version=2)

Commandline Tool
================
You can run commands to the OpenPhoto API from your shell!
You can run commands to the Trovebox API from your shell!

These are the options you can pass to the shell program::

--help # Display help text
-c config_file # Either the name of a config file in ~/.config/openphoto/ or a full path to a config file
-c config_file # Either the name of a config file in ~/.config/trovebox/ or a full path to a config file
-h hostname # Overrides config_file for unauthenticated API calls
-e endpoint # [default=/photos/list.json]
-X method # [default=GET]
Expand All @@ -98,9 +99,9 @@ These are the options you can pass to the shell program::

Commandline Examples
--------------------
Upload a public photo to the host specified in ```~/.config/openphoto/default```::
Upload a public photo to the host specified in ```~/.config/trovebox/default```::

openphoto -p -X POST -e /photo/upload.json -F 'photo=@/path/to/photo/jpg' -F 'permission=1'
trovebox -p -X POST -e /photo/upload.json -F 'photo=@/path/to/photo/jpg' -F 'permission=1'
{
"code":201,
"message":"Photo 1eo uploaded successfully",
Expand All @@ -112,9 +113,9 @@ Upload a public photo to the host specified in ```~/.config/openphoto/default```
}
}

Get a thumbnail URL from current.openphoto.me (unauthenticated access)::
Get a thumbnail URL from current.trovebox.com (unauthenticated access)::

openphoto -h current.openphoto.me -p -e /photo/62/view.json -F 'returnSizes=20x20'
openphoto -h current.trovebox.com -p -e /photo/62/view.json -F 'returnSizes=20x20'
{
"code":200,
"message":"Photo 62",
Expand All @@ -125,11 +126,11 @@ Get a thumbnail URL from current.openphoto.me (unauthenticated access)::
],
...
...
"path20x20":"http://current.openphoto.me/photo/62/create/36c0a/20x20.jpg",
"pathBase":"http://awesomeness.openphoto.me/base/201203/7ae997-Boracay-Philippines-007.jpg",
"path20x20":"http://current.trovebox.com/photo/62/create/36c0a/20x20.jpg",
"pathBase":"http://awesomeness.trovebox.com/base/201203/7ae997-Boracay-Philippines-007.jpg",
"permission":"1",
"photo20x20":[
"http://current.openphoto.me/photo/62/create/36c0a/20x20.jpg",
"http://current.trovebox.com/photo/62/create/36c0a/20x20.jpg",
13,
20
],
Expand Down
4 changes: 0 additions & 4 deletions bin/openphoto

This file was deleted.

4 changes: 4 additions & 0 deletions bin/trovebox
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python

import trovebox.main
trovebox.main.main()
35 changes: 0 additions & 35 deletions openphoto/__init__.py

This file was deleted.

20 changes: 10 additions & 10 deletions run_functional_tests
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,36 @@ tput setaf 3
echo
echo "Testing latest self-hosted site..."
tput sgr0
export OPENPHOTO_TEST_CONFIG=test
unset OPENPHOTO_TEST_SERVER_API
export TROVEBOX_TEST_CONFIG=test
unset TROVEBOX_TEST_SERVER_API
python -m unittest discover --catch tests/functional

# Test server running APIv1 OpenPhoto instance
# Test server running APIv1 Trovebox instance
# Install from photo/frontend commit 660b2ab
tput setaf 3
echo
echo "Testing APIv1 self-hosted site..."
tput sgr0
export OPENPHOTO_TEST_CONFIG=test-apiv1
export OPENPHOTO_TEST_SERVER_API=1
export TROVEBOX_TEST_CONFIG=test-apiv1
export TROVEBOX_TEST_SERVER_API=1
python -m unittest discover --catch tests/functional

# Test server running v3.0.8 OpenPhoto instance
# Test server running v3.0.8 Trovebox instance
# Install from photo/frontend commit e9d81de57b
tput setaf 3
echo
echo "Testing v3.0.8 self-hosted site..."
tput sgr0
export OPENPHOTO_TEST_CONFIG=test-3.0.8
unset OPENPHOTO_TEST_SERVER_API
export TROVEBOX_TEST_CONFIG=test-3.0.8
unset TROVEBOX_TEST_SERVER_API
python -m unittest discover --catch tests/functional

# Test account on hosted trovebox.com site
tput setaf 3
echo
echo "Testing latest hosted site..."
tput sgr0
export OPENPHOTO_TEST_CONFIG=test-hosted
unset OPENPHOTO_TEST_SERVER_API
export TROVEBOX_TEST_CONFIG=test-hosted
unset TROVEBOX_TEST_SERVER_API
python -m unittest discover --catch tests/functional

17 changes: 9 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
requires = ['requests', 'requests_oauthlib']

console_script = """[console_scripts]
openphoto = openphoto.main:main
trovebox = trovebox.main:main
"""

# from openphoto._version import __version__
exec(open("openphoto/_version.py").read())
# from trovebox._version import __version__
exec(open("trovebox/_version.py").read())

# Check the Python version
(major, minor) = sys.version_info[:2]
Expand All @@ -23,18 +23,19 @@
}
except ImportError:
from distutils.core import setup
kw = {'scripts': ['bin/openphoto'],
kw = {'scripts': ['bin/trovebox'],
'requires': requires}

setup(name='openphoto',
setup(name='trovebox',
version=__version__,
description='The official Python client library for Trovebox/OpenPhoto',
description='The official Python client library for the Trovebox photo service',
long_description=open("README.rst").read(),
author='Pete Burgers, James Walker',
url='https://github.com/photo/openphoto-python',
packages=['openphoto'],
packages=['trovebox'],
data_files=['README.rst'],
keywords=['openphoto', 'pyopenphoto', 'openphoto-python', 'trovebox'],
keywords=['openphoto', 'pyopenphoto', 'openphoto-python',
'trovebox', 'pytrovebox', 'openphoto-trovebox'],
classifiers=['Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
Expand Down
6 changes: 3 additions & 3 deletions tests/README.markdown
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OpenPhoto/Trovebox Python Testing
Trovebox Python Testing
=======================

###Unit Tests
Expand Down Expand Up @@ -26,8 +26,8 @@ To run the unit tests against all supported Python versions, use ```tox```:

###Functional Tests

The functional tests check that the openphoto-python library interoperates
correctly with a real OpenPhoto/Trovebox server.
The functional tests check that the Trovebox python library interoperates
correctly with a real Trovebox server.

They are slow to run and rely on a stable HTTP connection to a test server.

Expand Down
30 changes: 15 additions & 15 deletions tests/functional/README.markdown
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
Functional Testing
=======================

These functional tests check that the openphoto-python library interoperates
correctly with a real OpenPhoto/Trovebox server.
These functional tests check that the Trovebox python library interoperates
correctly with a real Trovebox server.

They are slow to run, and require a stable HTTP connection to a test server.

----------------------------------------
<a name="requirements"></a>
### Requirements
A computer, Python and an empty OpenPhoto/Trovebox test host.
A computer, Python and an empty Trovebox test host.

---------------------------------------
<a name="setup"></a>
### Setting up

Create a ``~/.config/openphoto/test`` config file containing the following:
Create a ``~/.config/trovebox/test`` config file containing the following:

# ~/.config/openphoto/test
# ~/.config/trovebox/test
host = your.host.com
consumerKey = your_consumer_key
consumerSecret = your_consumer_secret
token = your_access_token
tokenSecret = your_access_token_secret

Make sure this is an empty test server, **not a production OpenPhoto server!!!**
Make sure this is an empty test server, **not a production Trovebox server!!!**

You can specify an alternate test config file with the following environment variable:

export OPENPHOTO_TEST_CONFIG=test2
export TROVEBOX_TEST_CONFIG=test2

---------------------------------------
<a name="running"></a>
Expand All @@ -37,28 +37,28 @@ You can specify an alternate test config file with the following environment var
The following instructions are for Python 2.7. You can adapt them for earlier
Python versions using the ``unittest2`` package.

cd /path/to/openphoto-python
cd /path/to/trovebox-python
python -m unittest discover -c tests/functional

The "-c" lets you stop the tests gracefully with \[CTRL\]-c.

The easiest way to run a subset of the tests is with the ``nose`` package:

cd /path/to/openphoto-python
cd /path/to/trovebox-python
nosetests -v -s --nologcapture tests/functional/test_albums.py:TestAlbums.test_view

All HTTP requests and responses are recorded in the file ``tests.log``.

You can enable more verbose output to stdout with the following environment variable:

export OPENPHOTO_TEST_DEBUG=1
export TROVEBOX_TEST_DEBUG=1

---------------------------------------
<a name="test_details"></a>
### Test Details

These tests are intended to verify the openphoto-python library.
They don't provide comprehensive testing of the OpenPhoto API,
These tests are intended to verify the Trovebox python library.
They don't provide comprehensive testing of the Trovebox API,
there are PHP unit tests for that.

Each test class is run as follows:
Expand All @@ -84,19 +84,19 @@ Remove all photos, tags and albums
By default, all currently supported API versions will be tested.
It's useful to test servers that only support older API versions.
To restrict the testing to a specific maximum API version, use the
``OPENPHOTO_TEST_SERVER_API`` environment variable.
``TROVEBOX_TEST_SERVER_API`` environment variable.

For example, to restrict testing to APIv1 and APIv2:

export OPENPHOTO_TEST_SERVER_API=2
export TROVEBOX_TEST_SERVER_API=2

<a name="full_regression"></a>
### Full Regression Test

The ``run_functional_tests`` script runs all functional tests against
all supported API versions.

To use it, you must set up multiple OpenPhoto instances and create the following
To use it, you must set up multiple Trovebox instances and create the following
config files containing your credentials:

test : Latest self-hosted site (from photo/frontend master branch)
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_albums.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_create_delete(self):

def test_update(self):
""" Test that an album can be updated """
# Update the album using the OpenPhoto class,
# Update the album using the Trovebox class,
# passing in the album object
new_name = "New Name"
self.client.album.update(self.albums[0], name=new_name)
Expand All @@ -38,7 +38,7 @@ def test_update(self):
self.albums = self.client.albums.list()
self.assertEqual(self.albums[0].name, new_name)

# Update the album using the OpenPhoto class, passing in the album id
# Update the album using the Trovebox class, passing in the album id
new_name = "Another New Name"
self.client.album.update(self.albums[0].id, name=new_name)

Expand Down
Loading

0 comments on commit 6f70330

Please sign in to comment.