Skip to content

Commit

Permalink
Create auction with merchandising object docs (#108)
Browse files Browse the repository at this point in the history
* Fix tests and add another tutorial test

* Generate new documentation

* Fix constants
  • Loading branch information
oleksiyVeretiuk authored and leits committed Jul 18, 2018
1 parent 8f418ee commit 9cb5fb4
Show file tree
Hide file tree
Showing 82 changed files with 1,299 additions and 996 deletions.
102 changes: 63 additions & 39 deletions docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@
from datetime import timedelta, datetime
from uuid import uuid4

from webtest import TestApp

from openprocurement.auctions.core.utils import get_now

from openprocurement.auctions.core.tests.base import PrefixedRequestClass
from openprocurement.auctions.core.tests.base import PrefixedRequestClass, snitch

import openprocurement.auctions.dgf.tests.base as base_test
from openprocurement.auctions.dgf.tests.base import test_auction_data as base_test_auction_data, test_bids, test_financial_bids
from openprocurement.auctions.dgf.tests.tender import BaseAuctionWebTest

now = datetime.now()

test_auction_data = base_test_auction_data.copy()
test_financial_auction_data = test_auction_data.copy()
test_financial_auction_data["procurementMethodType"] = "DGFFinancial"
test_financial_auction_data["procurementMethodType"] = "DGFFinancialAssets"

bid = {
"data": {
Expand Down Expand Up @@ -193,48 +190,63 @@
}


class DumpsTestAppwebtest(TestApp):
def do_request(self, req, status=None, expect_errors=None):
req.headers.environ["HTTP_HOST"] = "api-sandbox.ea.openprocurement.org"
if hasattr(self, 'file_obj') and not self.file_obj.closed:
self.file_obj.write(req.as_bytes(True))
self.file_obj.write("\n")
if req.body:
try:
self.file_obj.write(
'\n' + json.dumps(json.loads(req.body), indent=2, ensure_ascii=False).encode('utf8'))
self.file_obj.write("\n")
except:
pass
self.file_obj.write("\n")
resp = super(DumpsTestAppwebtest, self).do_request(req, status=status, expect_errors=expect_errors)
if hasattr(self, 'file_obj') and not self.file_obj.closed:
headers = [(n.title(), v)
for n, v in resp.headerlist
if n.lower() != 'content-length']
headers.sort()
self.file_obj.write(str('\n%s\n%s\n') % (
resp.status,
str('\n').join([str('%s: %s') % (n, v) for n, v in headers]),
))

if resp.testbody:
try:
self.file_obj.write('\n' + json.dumps(json.loads(resp.testbody), indent=2, ensure_ascii=False).encode('utf8'))
except:
pass
self.file_obj.write("\n\n")
return resp
# class DumpsTestAppwebtest(TestApp):
def do_request(self, req, status=None, expect_errors=None, base_do_request=None):
req.headers.environ["HTTP_HOST"] = "api-sandbox.ea.openprocurement.org"
if hasattr(self, 'file_obj') and not self.file_obj.closed:
self.file_obj.write(req.as_bytes(True))
self.file_obj.write("\n")
if req.body:
try:
self.file_obj.write(
'\n' + json.dumps(json.loads(req.body), indent=2, ensure_ascii=False).encode('utf8'))
self.file_obj.write("\n")
except:
pass
self.file_obj.write("\n")
resp = base_do_request(req, status=status, expect_errors=expect_errors)
if hasattr(self, 'file_obj') and not self.file_obj.closed:
headers = [(n.title(), v)
for n, v in resp.headerlist
if n.lower() != 'content-length']
headers.sort()
self.file_obj.write(str('\n%s\n%s\n') % (
resp.status,
str('\n').join([str('%s: %s') % (n, v) for n, v in headers]),
))

if resp.testbody:
try:
self.file_obj.write('\n' + json.dumps(json.loads(resp.testbody), indent=2, ensure_ascii=False).encode('utf8'))
except:
pass
self.file_obj.write("\n\n")
return resp


def write_to_file(self, func):

def wrapper(*args, **kwargs):
kwargs['base_do_request'] = func
return do_request(self, *args, **kwargs)

return wrapper


class AuctionResourceTest(BaseAuctionWebTest):
initial_data = test_auction_data
initial_bids = test_bids
docservice = True



@classmethod
def setUpClass(cls):
super(AuctionResourceTest, cls).setUpClass()
cls.app.do_request = write_to_file(cls.app, cls.app.do_request)

def setUp(self):
self.app = DumpsTestAppwebtest(
"config:tests.ini", relative_to=os.path.dirname(base_test.__file__))
super(AuctionResourceTest, self).setUp()
self.app.RequestClass = PrefixedRequestClass
self.app.authorization = ('Basic', ('broker', ''))
self.couchdb_server = self.app.app.registry.couchdb_server
Expand Down Expand Up @@ -1520,3 +1532,15 @@ def test_docs_fintutorial(self):
bid2_id = response.json['data']['id']
bids_access[bid2_id] = response.json['access']['token']
self.assertEqual(response.status, '201 Created')

def test_create_procedure_from_lot_tutorial(self):
# Creating auction with merchandisingObject
#
data = test_auction_data.copy()
data['status'] = 'draft'
data['merchandisingObject'] = uuid4().hex

with open('docs/source/tutorial/auction-post-merchandisingObject.http', 'w') as self.app.file_obj:
response = self.app.post_json(
'/auctions?opt_pretty=1', {"data": data})
self.assertEqual(response.status, '201 Created')
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
# ones.
import cornice
extensions = [
'cornice.ext.sphinxext',
'sphinx.ext.intersphinx',
'sphinx.ext.graphviz',
'sphinxcontrib.httpdomain',
Expand Down
46 changes: 22 additions & 24 deletions docs/source/qualification/award-active-disqualify.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PATCH /api/2.3/auctions/259c7703ce68422e8c436195e56505bf/awards/7d925e654ad942bd865f4bac5c6e34d1?acc_token=90b60080a3a045f2b487d17fbbccf77a HTTP/1.0
PATCH /api/2.5/auctions/d703c42df3b9428c91119666efc96d32/awards/1af9e5d03c144172a542e0a9b736f5ff?acc_token=a2774a39522b480fb72b3b6f8d291c96 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 146
Content-Type: application/json
Expand All @@ -14,43 +14,41 @@ Host: api-sandbox.ea.openprocurement.org


200 OK
Content-Type: application/json; charset=UTF-8
Content-Type: application/json
X-Content-Type-Options: nosniff

{
"data": {
"status": "unsuccessful",
"paymentPeriod": {
"startDate": "2018-03-13T14:17:00.465960+02:00"
},
"documents": [
{
"dateModified": "2018-03-13T14:17:00.574662+02:00",
"hash": "md5:00000000000000000000000000000000",
"format": "application/pdf",
"url": "http://public.docs-sandbox.ea.openprocurement.org/get/27e90f8b3a4a44548f39c9f566a24c6f?KeyID=4a8daaf3&Signature=rQY4T5kNmZAb4sUTXeBO%252BORoWHwlrqNbV7%2FSlGprf8VdusX4zTcBDBFuWcQvGzLbiwut7lhCSQ2ZfxFZiu3lCQ%253D%253D",
"author": "bid_owner",
"title": "auction_protocol.pdf",
"url": "http://public.docs-sandbox.ea.openprocurement.org/get/0e9d83c40bda4ee686b1ee770f4ae29d?KeyID=172d32c8&Signature=KF2%2F0siIuSjSWeLo4w1mQYg4aXF9E996sRRLaLZQyMpPSVReZ69CQ%2F1k43228sZWTwytyB3JVPnA%2FlmZvNYGBw%253D%253D",
"format": "application/pdf",
"documentOf": "tender",
"datePublished": "2018-03-13T14:17:00.574642+02:00",
"datePublished": "2018-07-11T15:06:05.985154+03:00",
"documentType": "auctionProtocol",
"title": "auction_protocol.pdf",
"id": "034c7a0a36aa453d8e12bf2d352b73f7"
"dateModified": "2018-07-11T15:06:05.985173+03:00",
"id": "d5f65b961f574b25acf9cbfa7a6ccf95"
},
{
"dateModified": "2018-03-13T14:17:00.666701+02:00",
"dateModified": "2018-07-11T15:06:06.085849+03:00",
"hash": "md5:00000000000000000000000000000000",
"description": "Disqualification reason",
"author": "auction_owner",
"url": "http://public.docs-sandbox.ea.openprocurement.org/get/67a0367308ce4269b22fa529bd772b79?KeyID=4a8daaf3&Signature=8uduzwaCrRZAEQLjv9b3qK3M9PjBGb%2FKnbQR8bXUueGXAQGFHV50QRRPNAuhjXS6%2F1eJ6JA5EqxFaCH6VQ4GBg%253D%253D",
"url": "http://public.docs-sandbox.ea.openprocurement.org/get/a792e87740b44405b4ab9341659886af?KeyID=172d32c8&Signature=DXm2Ng5SUJpzDB0RA6H3TScf122R9VY7fRBS4JkzO1FYghCTcKxSngm0YcI%252BVrCyXFTwEKmFHFqSv3wRpn3tCQ%253D%253D",
"format": "application/pdf",
"documentOf": "tender",
"datePublished": "2018-03-13T14:17:00.666680+02:00",
"datePublished": "2018-07-11T15:06:06.085830+03:00",
"title": "Disqualified_reason.pdf",
"id": "a98b4c463580499bb1a47c92f918485c"
"id": "aed404c5e956422f90d00d8f255b4198"
}
],
"verificationPeriod": {
"startDate": "2018-03-13T14:17:00.465960+02:00",
"endDate": "2018-03-13T14:17:00.769362+02:00"
"startDate": "2018-07-11T15:06:05.868405+03:00",
"endDate": "2018-07-11T15:06:06.195718+03:00"
},
"description": "Candidate didn’t sign the auction protocol in 3 business days",
"title": "Disqualified",
Expand All @@ -77,20 +75,20 @@ Content-Type: application/json; charset=UTF-8
}
],
"complaintPeriod": {
"startDate": "2018-03-13T14:17:00.204168+02:00",
"endDate": "2018-03-13T14:17:00.769362+02:00"
"startDate": "2018-07-11T15:06:05.564780+03:00",
"endDate": "2018-07-11T15:06:06.195718+03:00"
},
"bid_id": "a4f299a1dcd54224bb9821e58e8d6675",
"bid_id": "7decb4064e5846949180ea56c86da1c0",
"value": {
"currency": "UAH",
"amount": 475.0,
"valueAddedTaxIncluded": true
},
"date": "2018-03-13T14:17:00.780676+02:00",
"id": "7d925e654ad942bd865f4bac5c6e34d1",
"date": "2018-07-11T15:06:06.204752+03:00",
"id": "1af9e5d03c144172a542e0a9b736f5ff",
"signingPeriod": {
"startDate": "2018-03-13T14:17:00.465960+02:00",
"endDate": "2018-03-13T14:37:08.924293+02:00"
"startDate": "2018-07-11T15:06:05.868405+03:00",
"endDate": "2018-07-11T15:26:12.281599+03:00"
}
}
}
Expand Down
19 changes: 10 additions & 9 deletions docs/source/qualification/award-active-unsuccessful-upload.http
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
POST /api/2.3/auctions/259c7703ce68422e8c436195e56505bf/awards/7d925e654ad942bd865f4bac5c6e34d1/documents?acc_token=90b60080a3a045f2b487d17fbbccf77a HTTP/1.0
POST /api/2.5/auctions/d703c42df3b9428c91119666efc96d32/awards/1af9e5d03c144172a542e0a9b736f5ff/documents?acc_token=a2774a39522b480fb72b3b6f8d291c96 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 382
Content-Length: 394
Content-Type: application/json
Host: api-sandbox.ea.openprocurement.org

{
"data": {
"url": "http://public.docs-sandbox.ea.openprocurement.org/get/67a0367308ce4269b22fa529bd772b79?KeyID=4a8daaf3&Signature=fl6vi6S9a5XBXhBXpljZdlUPpYcQoG01LzhyfOMWeIzySemTOo%2FibA62MLZYHJRh3AL3hsgu7ADOkl1tKe90DQ%3D%3D",
"url": "http://public.docs-sandbox.ea.openprocurement.org/get/a792e87740b44405b4ab9341659886af?KeyID=172d32c8&Signature=WJZUGD%2FrehJ%2FHMc2FF88pjA%2FbN%2FQvM8hd5fX%2FKXQr0NAOeD2WItWk2FSokhKqovJmOa954%2BzDTha7h%2Bfpn19BQ%3D%3D",
"title": "Disqualified_reason.pdf",
"hash": "md5:00000000000000000000000000000000",
"description": "Disqualification reason",
Expand All @@ -16,21 +16,22 @@ Host: api-sandbox.ea.openprocurement.org


201 Created
Content-Type: application/json; charset=UTF-8
Location: http://api-sandbox.ea.openprocurement.org/api/2.3/auctions/259c7703ce68422e8c436195e56505bf/awards/7d925e654ad942bd865f4bac5c6e34d1/documents/a98b4c463580499bb1a47c92f918485c
Content-Type: application/json
Location: http://api-sandbox.ea.openprocurement.org/api/2.5/auctions/d703c42df3b9428c91119666efc96d32/awards/1af9e5d03c144172a542e0a9b736f5ff/documents/aed404c5e956422f90d00d8f255b4198
X-Content-Type-Options: nosniff

{
"data": {
"dateModified": "2018-03-13T14:17:00.666701+02:00",
"dateModified": "2018-07-11T15:06:06.085849+03:00",
"hash": "md5:00000000000000000000000000000000",
"description": "Disqualification reason",
"author": "auction_owner",
"url": "http://public.docs-sandbox.ea.openprocurement.org/get/67a0367308ce4269b22fa529bd772b79?KeyID=4a8daaf3&Signature=8uduzwaCrRZAEQLjv9b3qK3M9PjBGb%2FKnbQR8bXUueGXAQGFHV50QRRPNAuhjXS6%2F1eJ6JA5EqxFaCH6VQ4GBg%253D%253D",
"url": "http://public.docs-sandbox.ea.openprocurement.org/get/a792e87740b44405b4ab9341659886af?KeyID=172d32c8&Signature=DXm2Ng5SUJpzDB0RA6H3TScf122R9VY7fRBS4JkzO1FYghCTcKxSngm0YcI%252BVrCyXFTwEKmFHFqSv3wRpn3tCQ%253D%253D",
"format": "application/pdf",
"documentOf": "tender",
"datePublished": "2018-03-13T14:17:00.666680+02:00",
"datePublished": "2018-07-11T15:06:06.085830+03:00",
"title": "Disqualified_reason.pdf",
"id": "a98b4c463580499bb1a47c92f918485c"
"id": "aed404c5e956422f90d00d8f255b4198"
}
}

15 changes: 8 additions & 7 deletions docs/source/qualification/award-waiting-cancel.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PATCH /api/2.3/auctions/0bbf22e936f24d158f6d695b84b2de2f/awards/aa7678ac3df24b7f8d502e693633057e?acc_token=3d81a5bab08b499fa57792f94a076401 HTTP/1.0
PATCH /api/2.5/auctions/bb1795e42a4243ada1433ddb18b4f06f/awards/f0b67608db9b41f6bef95fc82a62f7c1?acc_token=035a14661c204ad9a32c92d733351401 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 33
Content-Type: application/json
Expand All @@ -12,14 +12,15 @@ Host: api-sandbox.ea.openprocurement.org


200 OK
Content-Type: application/json; charset=UTF-8
Content-Type: application/json
X-Content-Type-Options: nosniff

{
"data": {
"status": "cancelled",
"complaintPeriod": {
"startDate": "2018-03-13T14:17:04.704323+02:00",
"endDate": "2018-03-13T14:17:04.876235+02:00"
"startDate": "2018-07-11T15:06:09.034064+03:00",
"endDate": "2018-07-11T15:06:09.218067+03:00"
},
"suppliers": [
{
Expand All @@ -43,14 +44,14 @@ Content-Type: application/json; charset=UTF-8
}
}
],
"bid_id": "be3bb6d966f34c7389a71bfdada36002",
"bid_id": "33e956525782481880696efc0dc83b4a",
"value": {
"currency": "UAH",
"amount": 500.0,
"valueAddedTaxIncluded": true
},
"date": "2018-03-13T14:17:04.883288+02:00",
"id": "aa7678ac3df24b7f8d502e693633057e"
"date": "2018-07-11T15:06:09.224192+03:00",
"id": "f0b67608db9b41f6bef95fc82a62f7c1"
}
}

9 changes: 9 additions & 0 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ Let's check what auction registry contains:
And indeed we have 2 auctions now.


Creating auction from the given lot
-----------------------------------
Let's create a procedure considering the lot created before within the registry:

.. include:: tutorial/auction-post-merchandisingObject.http
:code:



Modifying auction
-----------------

Expand Down
9 changes: 5 additions & 4 deletions docs/source/tutorial/activate-bidder.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PATCH /api/2.3/auctions/0bbf22e936f24d158f6d695b84b2de2f/bids/be3bb6d966f34c7389a71bfdada36002?acc_token=3d81a5bab08b499fa57792f94a076401 HTTP/1.0
PATCH /api/2.5/auctions/bb1795e42a4243ada1433ddb18b4f06f/bids/33e956525782481880696efc0dc83b4a?acc_token=035a14661c204ad9a32c92d733351401 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 30
Content-Type: application/json
Expand All @@ -12,7 +12,8 @@ Host: api-sandbox.ea.openprocurement.org


200 OK
Content-Type: application/json; charset=UTF-8
Content-Type: application/json
X-Content-Type-Options: nosniff

{
"data": {
Expand All @@ -22,7 +23,7 @@ Content-Type: application/json; charset=UTF-8
"amount": 500.0,
"valueAddedTaxIncluded": true
},
"date": "2018-03-13T14:17:04.076622+02:00",
"date": "2018-07-11T15:06:08.268644+03:00",
"qualified": true,
"tenderers": [
{
Expand All @@ -47,7 +48,7 @@ Content-Type: application/json; charset=UTF-8
}
],
"owner": "broker",
"id": "be3bb6d966f34c7389a71bfdada36002"
"id": "33e956525782481880696efc0dc83b4a"
}
}

5 changes: 3 additions & 2 deletions docs/source/tutorial/activate-finbidder.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PATCH /api/2.3/auctions/72f943f337ff4470acaa2e958316ecc3/bids/75657b393358497898e6a1e531b7362e?acc_token=f1eb099213b94ce086c3241560a4fb67 HTTP/1.0
PATCH /api/2.5/auctions/1bd0478dee5b4b0581e2d1bf7f47fa51/bids/2f94ff64e9854aeb8083c26bf5a85ab0?acc_token=de594836f1544ab69b444235f3f05693 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 30
Content-Type: application/json
Expand All @@ -12,7 +12,8 @@ Host: api-sandbox.ea.openprocurement.org


200 OK
Content-Type: application/json; charset=UTF-8
Content-Type: application/json
X-Content-Type-Options: nosniff

null

Loading

0 comments on commit 9cb5fb4

Please sign in to comment.