add org
This commit is contained in:
@@ -1,11 +1,46 @@
|
||||
import json
|
||||
from http import HTTPMethod, HTTPStatus
|
||||
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair, PartitionKey
|
||||
|
||||
from ..conftest import HttpApiProxy, LambdaContext
|
||||
|
||||
|
||||
def test_add_org(
|
||||
app,
|
||||
seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
http_api_proxy: HttpApiProxy,
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
user_id = '213a6682-2c59-4404-9189-12eec0a846d4'
|
||||
r = app.lambda_handler(
|
||||
http_api_proxy(
|
||||
raw_path='/orgs',
|
||||
method=HTTPMethod.POST,
|
||||
body={
|
||||
'name': 'Banco Central do Brasil',
|
||||
'cnpj': '00038166000105',
|
||||
'user': {
|
||||
'id': user_id,
|
||||
'name': 'Sérgio R Siqueira',
|
||||
'email': 'sergio@somosbeta.com.br',
|
||||
},
|
||||
},
|
||||
),
|
||||
lambda_context,
|
||||
)
|
||||
body = json.loads(r['body'])
|
||||
assert r['statusCode'] == HTTPStatus.CREATED
|
||||
|
||||
org = dynamodb_persistence_layer.collection.query(PartitionKey(body['id']))
|
||||
assert len(org['items']) == 3
|
||||
|
||||
user = dynamodb_persistence_layer.collection.query(KeyPair(user_id, 'orgs#'))
|
||||
# One item was added from seeds
|
||||
assert len(user['items']) == 2
|
||||
|
||||
|
||||
def test_get_admins(
|
||||
app,
|
||||
seeds,
|
||||
@@ -28,7 +63,6 @@ def test_get_admins(
|
||||
def test_revoke(
|
||||
app,
|
||||
seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
http_api_proxy: HttpApiProxy,
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user