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

Updates CI configuration #14

Merged
merged 5 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
__pycache__/
build/
.tox/
.coverage
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ matrix:
- python: "3.7"
env: TOXENV=py37

# Linters

- python: "3.7"
- python: "3.6"
env: TOXENV=linting

notifications:
Expand Down
33 changes: 9 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,26 @@
# ElectronBonder
A client library for working with the Project Electron APIs.

## Credits
This code is basically stolen from [ArchivesSnake](https://github.com/archivesspace-labs/ArchivesSnake/).

## Requirements
ElectronBonder has the following requirements.
## Getting started

- Python 3.4 or higher
- ability to install packages via pip ([Pipenv](https://docs.pipenv.org/) is recommended for development)

## Installation
The easiest way to install ElectronBonder is via pip:
Make sure this library is installed:

pip3 install ElectronBonder

You'll need an internet connection to fetch ElectronBonder's dependencies.

## Usage
To start, you must create a client with a baseurl:
Then create a client with a baseurl, a username and a password:

``` python
from electronbonder.client import ElectronBond

client = ElectronBond(baseurl="http://my.aspace.backend.url.edu:4567")
client = ElectronBond(
baseurl="http://my.aspace.backend.url.edu:4567",
username="admin",
password="TopSecr3t")
```


## Configuration

As per the example above, the client object should be configured by passing it arguments during creation.

Allowed configuration values are:

| **Setting** | **Description** |
|-------------|-------------------------------------------------------------------------------|
| baseurl | The location (including port if not on port 80) of the application's API root |
## Credits
This code is basically stolen from [ArchivesSnake](https://github.com/archivesspace-labs/ArchivesSnake/).


## License
Expand Down
7 changes: 2 additions & 5 deletions electronbonder/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,12 @@ def __init__(self, **config):
self.session.headers.update({"Accept": "application/json",
"User-Agent": "ElectronBond/0.1"})

def authorize(self, username=None, password=None):
def authorize(self):
"""Authorizes the client against the configured microservice instance."""

username = username or self.config["username"]
password = password or self.config["password"]

resp = self.session.post(
"/".join([self.config["baseurl"].rstrip("/"), "get-token/"]),
data={"password": password, "username": username})
data={"password": self.config["password"], "username": self.config["username"]})

if resp.status_code != 200:
raise ElectronBondAuthError(
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ deps =
pytest
requests
six
coverage
skip_install = True
commands = pytest
commands =
coverage run -m --source=./electronbonder pytest -s
coverage report -m

[testenv:linting]
basepython = python3
Expand Down