Skip to content

Commit

Permalink
Merge pull request #21 from kukirokuk/a679817978969388_assets_tutoria…
Browse files Browse the repository at this point in the history
…l_fix_and_docs.py

Fix docs.py docs and test data
  • Loading branch information
leits committed May 23, 2018
2 parents 14c38a8 + 48e20a4 commit c18fe87
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 33 deletions.
20 changes: 12 additions & 8 deletions docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from openregistry.assets.bounce.tests.base import BaseAssetWebTest
from openregistry.assets.bounce.tests.json_data import test_asset_bounce_data

DumpsTestAppwebtest.hostname = "lb.api-sandbox.registry.ea2.openprocurement.net"

class AssetResourceTest(BaseAssetWebTest):

Expand Down Expand Up @@ -81,10 +82,11 @@ def test_docs_tutorial(self):
with open('docs/source/tutorial/create-second-asset.http', 'w') as self.app.file_obj:
response = self.app.post_json(request_path, {"data": self.initial_data})
self.assertEqual(response.status, '201 Created')

asset_id_2 = response.json['data']['id']
owner_token_2 = response.json['access']['token']

with open('docs/source/tutorial/pending-second-asset.http', 'w') as self.app.file_obj:
response = self.app.patch_json('/{}?acc_token={}'.format(asset_id, owner_token),
response = self.app.patch_json('/{}?acc_token={}'.format(asset_id_2, owner_token_2),
{'data': {"status": 'pending'}})
self.assertEqual(response.status, '200 OK')

Expand Down Expand Up @@ -143,16 +145,18 @@ def test_docs_tutorial_with_concierge(self):
{'data': {"status": 'pending'}})
self.assertEqual(response.status, '200 OK')

# Switch to Active
# Switch to Verification
#
self.app.authorization = ('Basic', ('concierge', ''))

response = self.app.patch_json('/{}'.format(asset_id),
{'data': {"status": 'verification',
"relatedLot": uuid4().hex}})
self.assertEqual(response.status, '200 OK')

with open('docs/source/tutorial/asset_switch_to_verification.http', 'w') as self.app.file_obj:
response = self.app.patch_json('/{}'.format(asset_id),
{'data': {"status": 'verification',
"relatedLot": uuid4().hex}})
self.assertEqual(response.status, '200 OK')

# Switch to Active
#
response = self.app.patch_json('/{}'.format(asset_id),
{'data': {"status": 'active'}})
self.assertEqual(response.status, '200 OK')
Expand Down
13 changes: 9 additions & 4 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,24 @@ Integration with lots

As long as the lot is formed, the system should verify whether the asset can be attached to that lot. With the lot status being changed to `verification` the asset automatically reaches `verification` as well.

In case of the asset being available, its status becomes `active`.
.. literalinclude:: tutorial/asset_switch_to_verification.http
:language: javascript

In case of the asset being available, its status automatically becomes `active`.

.. literalinclude:: tutorial/attached-to-lot-asset-view.http
:language: javascript

If the lot is formed incorrectly, the asset will receive `pending` status.
If the lot is formed incorrectly, the asset will automatically receive `pending` status and so that the `relatedLot` field will be empty.

.. literalinclude:: tutorial/detached-from-lot-asset-view.http
:language: javascript

As long as the lot status becomes either `pending.deleted` or `pending.dissolution`, the asset attached to that lot receives `pending` status.

..............................
As long as the lot status becomes either `pending.deleted` or `pending.dissolution`, the asset attached to that lot also receives `pending` status.

.. literalinclude:: tutorial/detached-from-lot-asset-view.http
:language: javascript

As long as the lot receives `pending.sold` status, the asset attached to that lot becomes `complete`.

Expand Down
6 changes: 3 additions & 3 deletions docs/source/tutorial/asset-listing-after-patch.http
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GET /api/2.4/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
GET /api/2.4/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Host: lb.api-sandbox.registry.ea2.openprocurement.net

Response: 200 OK
Expand All @@ -14,7 +14,7 @@ X-Content-Type-Options: nosniff
"data": [
{
"id": "5c8cd4c766c74f60b25b2b9cdbfb8ef7",
"dateModified": "2018-05-22T13:39:54.510132+03:00"
"dateModified": "2018-05-22T13:40:23.343097+03:00"
}
]
}
Expand Down
20 changes: 6 additions & 14 deletions docs/source/tutorial/asset-post-2pc.http
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
POST /api/2.4/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 2734
Content-Type: application/json
POST /api/2.4/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 2734
Content-Type: application/json
Host: lb.api-sandbox.registry.ea2.openprocurement.net
DATA:
{
Expand Down Expand Up @@ -30,7 +30,6 @@ DATA:
"address": {
"countryName": "Ukraine"
},
"id": "0",
"unit": {
"code": "code"
},
Expand All @@ -56,7 +55,6 @@ DATA:
"address": {
"countryName": "Ukraine"
},
"id": "0",
"unit": {
"code": "code"
},
Expand All @@ -76,16 +74,10 @@ DATA:
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
"id": "00037256"
},
"name": "Державне управління справами",
"address": {
"countryName": "Україна",
"postalCode": "01220",
"region": "м. Київ",
"streetAddress": "вул. Банкова, 11, корпус 1",
"locality": "м. Київ"
"countryName": "Україна"
}
}
}
Expand Down
119 changes: 119 additions & 0 deletions docs/source/tutorial/asset_switch_to_verification.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
PATCH /api/2.4/assets/e5ad643dfbbf4689a1adfec69f254603 HTTP/1.0
Authorization: Basic Y29uY2llcmdlOg==
Content-Length: 86
Content-Type: application/json
Host: lb.api-sandbox.registry.ea2.openprocurement.net
DATA:
{
"data": {
"status": "verification",
"relatedLot": "888fa9fe1a544efd962c013a23b3277f"
}
}

Response: 200 OK
Content-Type: application/json
X-Content-Type-Options: nosniff
{
"data": {
"status": "verification",
"relatedLot": "888fa9fe1a544efd962c013a23b3277f",
"rectificationPeriod": {
"startDate": "2018-05-23T13:21:12.727792+03:00",
"endDate": "2018-05-24T13:21:12.727792+03:00"
},
"documents": [
{
"title": "Інформація про оприлюднення інформаційного повідомлення",
"url": "https://prozorro.sale/info/ssp_details ",
"documentOf": "asset",
"datePublished": "2018-05-23T13:21:12.647141+03:00",
"documentType": "informationDetails",
"dateModified": "2018-05-23T13:21:12.647227+03:00",
"id": "9f159b4177524cedb71231de6843cd1d"
}
],
"description": "Опис землі для космодрому",
"title": "Земля для космодрому",
"assetID": "UA-AR-DGF-2018-05-23-000001",
"assetType": "bounce",
"dateModified": "2018-05-23T13:21:12.808217+03:00",
"owner": "broker",
"items": [
{
"registrationDetails": {
"status": "unknown"
},
"description": "футляри до державних нагород",
"classification": {
"scheme": "CAV-PS",
"description": "Description",
"id": "06121000-6"
},
"additionalClassifications": [
{
"scheme": "UA-EDR",
"description": "папір і картон гофровані, паперова й картонна тара",
"id": "17.21.1"
}
],
"address": {
"countryName": "Ukraine"
},
"id": "5be78bff843544d8babc11965f3509d8",
"unit": {
"code": "code"
},
"quantity": 5.0001
},
{
"registrationDetails": {
"status": "unknown"
},
"description": "футляри до державних нагород",
"classification": {
"scheme": "CAV-PS",
"description": "Description",
"id": "06121000-6"
},
"additionalClassifications": [
{
"scheme": "UA-EDR",
"description": "папір і картон гофровані, паперова й картонна тара",
"id": "17.21.1"
}
],
"address": {
"countryName": "Ukraine"
},
"id": "3efae29fac6a4f0f9a742c143d9b9e91",
"unit": {
"code": "code"
},
"quantity": 5.0001
}
],
"date": "2018-05-23T13:21:12.807966+03:00",
"decisions": [
{
"decisionDate": "2018-05-23T13:21:10.853759+03:00",
"decisionID": "1111-4"
}
],
"id": "e5ad643dfbbf4689a1adfec69f254603",
"assetCustodian": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256"
},
"address": {
"countryName": "Україна"
}
}
}
}

8 changes: 6 additions & 2 deletions docs/source/tutorial/listing-with-some-assets.http
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GET /api/2.4/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
GET /api/2.4/assets?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Host: lb.api-sandbox.registry.ea2.openprocurement.net

Response: 200 OK
Expand All @@ -15,6 +15,10 @@ X-Content-Type-Options: nosniff
{
"id": "5c8cd4c766c74f60b25b2b9cdbfb8ef7",
"dateModified": "2018-05-22T13:39:54.510132+03:00"
},
{
"id": "f9954df58b5c4f40a7ba11f1eae6063c",
"dateModified": "2018-05-22T13:39:54.510132+03:00"
}
]
}
Expand Down
5 changes: 3 additions & 2 deletions openregistry/assets/bounce/tests/json_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from copy import deepcopy
from openregistry.assets.core.tests.blanks.json_data import (
test_organization,
test_organization_loki,
schema_properties,
test_loki_item_data
)
Expand All @@ -12,6 +12,7 @@
)

test_item_data = deepcopy(test_loki_item_data)
del test_item_data['id']

# test_loki_item_data['schema_properties'] = schema_properties
asset_type = os.environ.get('ASSET_TYPE', 'bounce')
Expand All @@ -20,7 +21,7 @@
"description": u"Опис землі для космодрому",
"assetType": asset_type,
"items": [test_item_data, test_item_data],
"assetCustodian": deepcopy(test_organization),
"assetCustodian": deepcopy(test_organization_loki),
"decisions": [{
'decisionDate': get_now().isoformat(),
'decisionID': '1111-4'
Expand Down

0 comments on commit c18fe87

Please sign in to comment.