I hereby claim:
- I am briancurtin on github.
- I am briancurtin (https://keybase.io/briancurtin) on keybase.
- I have a public key ASAD1UrmrzKbosUDLMpcaWgTE4zruWMczBIhY9kZhyc_wAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
(mypytest) temp $ cat test.py | |
from typing import List | |
def fn(x: str, y: bool=True, **kwargs: List[str]) -> None: | |
print(x, y, kwargs) | |
# ok | |
fn("hello", y=False) | |
# ok | |
fn("hello", kw1=["a", "b"], kw2=["c", "d"]) |
Like other Python code, tests are organized in a package structure,
but naming becomes significant. You can name the package anything—in our case
it's everything under tests.unit—but the test modules themselves need
to be prefixed with "test", e.g., tests.unit.api.test_utils
. Inside
those modules, classes that subclass unittest.TestCase
are imported
by the test runner, and methods on those subclasses that begin with "test"
are executed. Sticking with the example, tests.unit.api.test_utils
includes two suites of TestCases, organized by the types of tokens we're
{ | |
"breakdown": { | |
"categories": [ | |
..., | |
{ | |
"count": 2, | |
"frequency": "0.0", | |
"name": "NTWRK: L2 Offering Configuration", | |
"ticketsA": [<list of tickets>], | |
"sources": { |
{ | |
"work_log": { | |
"range": "2017-08-01,2017-08-01", | |
"tickets": [ | |
{ | |
"39365056": { | |
"count": 1, | |
"duration": 1, | |
"entries": [ | |
{ |
{ | |
"count": 146, | |
"duration": 2740, | |
"tickets": [ | |
{ | |
"39365056": { | |
"total_duration": 1, | |
"work_log_entries": [ | |
{ | |
"duration": 1, |
THE_API = "https://blah.com/v1" | |
class MyClient(requests.session): | |
def __init__(self, username, password): | |
self._token = None | |
def get_token(self): | |
response = self.get("api.com/auth", | |
headers={"user": self.username, |
~ $ curl -g -i -X GET http://127.0.0.1:5000/analytics/tickets/breakdown -H "token: asdf" | |
HTTP/1.0 200 OK | |
Content-Type: application/json | |
Content-Length: 1675 | |
Server: Werkzeug/0.12.2 Python/3.5.2 | |
Date: Tue, 25 Jul 2017 18:03:13 GMT | |
{ | |
"breakdown": { | |
"categories": [ |
~ $ curl -g -i -X GET http://127.0.0.1:5000/analytics/ticket_breakdown -H "token: asdf" | |
HTTP/1.0 200 OK | |
Content-Type: application/json | |
Content-Length: 2578 | |
Server: Werkzeug/0.12.2 Python/3.5.2 | |
Date: Mon, 24 Jul 2017 18:20:59 GMT | |
{ | |
"categories": [ | |
{ |
import sys | |
from openstack import connection | |
conn = connection.Connection(auth_url="url", username="user", password="pw", project_name="name", user_domain_id="default", project_domain_id="default") | |
token = conn.authorize() | |
# This could be another app, the same one, etc. | |
another_conn = connection.Connection(auth_url="url", token=token, auth_plugin="token") |