Skip to content

Commit

Permalink
Merge pull request #7 from VolVoz/master
Browse files Browse the repository at this point in the history
Документи Award-a i Contract-a в документації
  • Loading branch information
vmaksymiv committed Feb 8, 2016
2 parents 3d8a891 + 858028e commit 2f10517
Show file tree
Hide file tree
Showing 24 changed files with 415 additions and 94 deletions.
73 changes: 59 additions & 14 deletions docs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
import json
import os
from datetime import timedelta

import openprocurement.tender.limited.tests.base as base_test
from openprocurement.api.models import get_now
from openprocurement.api.tests.base import PrefixedRequestClass
from openprocurement.tender.limited.tests.tender import BaseTenderWebTest
from webtest import TestApp
Expand Down Expand Up @@ -108,7 +106,9 @@
}
}


class DumpsTestAppwebtest(TestApp):

def do_request(self, req, status=None, expect_errors=None):
req.headers.environ["HTTP_HOST"] = "api-sandbox.openprocurement.org"
if not self.file_obj.closed:
Expand Down Expand Up @@ -142,7 +142,7 @@ def do_request(self, req, status=None, expect_errors=None):
return resp


class TenderUAResourceTest(BaseTenderWebTest):
class TenderLimitedResourceTest(BaseTenderWebTest):
initial_data = test_tender_data

def setUp(self):
Expand Down Expand Up @@ -188,7 +188,6 @@ def test_docs(self):
}
})


with open('docs/source/tutorial/tender-listing-after-patch.http', 'w') as self.app.file_obj:
self.app.authorization = None
response = self.app.get(request_path)
Expand All @@ -207,7 +206,6 @@ def test_docs(self):

doc_id = response.json["data"]["id"]


with open('docs/source/tutorial/update-tender-notice.http', 'w') as self.app.file_obj:
response = self.app.put('/tenders/{}/documents/{}'.format(
self.tender_id, doc_id), upload_files=[('file', 'Notice-2.pdf', 'content2')])
Expand All @@ -220,23 +218,71 @@ def test_docs(self):
response = self.app.post_json('/tenders/{}/awards?acc_token={}'.format(
self.tender_id, owner_token), supplier)
self.assertEqual(response.status, '201 Created')
self.award_id = response.json['data']['id']

#### Uploading Award documentation
#

with open('docs/source/tutorial/tender-award-upload-document.http', 'w') as self.app.file_obj:
response = self.app.post('/tenders/{}/awards/{}/documents'.format(
self.tender_id, self.award_id), upload_files=[('file', 'award_first_document.doc', 'content')])
self.assertEqual(response.status, '201 Created')

with open('docs/source/tutorial/tender-award-get-documents.http', 'w') as self.app.file_obj:
response = self.app.get('/tenders/{}/awards/{}/documents'.format(
self.tender_id, self.award_id))
self.assertEqual(response.status, '200 OK')

with open('docs/source/tutorial/tender-award-upload-second-document.http', 'w') as self.app.file_obj:
response = self.app.post('/tenders/{}/awards/{}/documents'.format(
self.tender_id, self.award_id), upload_files=[('file', 'award_second_document.doc', 'content')])
self.assertEqual(response.status, '201 Created')

award_id = response.json['data']['id']
with open('docs/source/tutorial/tender-award-get-documents-again.http', 'w') as self.app.file_obj:
response = self.app.get('/tenders/{}/awards/{}/documents'.format(
self.tender_id, self.award_id))
self.assertEqual(response.status, '200 OK')

#### Award confirmation
#

with open('docs/source/tutorial/tender-award-approve.http', 'w') as self.app.file_obj:
response = self.app.patch_json('/tenders/{}/awards/{}?acc_token={}'.format(
self.tender_id, award_id, owner_token), {'data': {'status': 'active'}})
self.tender_id, self.award_id, owner_token), {'data': {'status': 'active'}})
self.assertEqual(response.status, '200 OK')

#### Contract signing
#### Contracts
#

response = self.app.get('/tenders/{}/contracts?acc_token={}'.format(
self.tender_id, owner_token))
contract_id = response.json['data'][0]['id']
self.tender_id, owner_token))
self.contract_id = response.json['data'][0]['id']

#### Uploading Contract documentation
#

with open('docs/source/tutorial/tender-contract-upload-document.http', 'w') as self.app.file_obj:
response = self.app.post('/tenders/{}/contracts/{}/documents'.format(
self.tender_id, self.contract_id), upload_files=[('file', 'contract_first_document.doc', 'content')])
self.assertEqual(response.status, '201 Created')

with open('docs/source/tutorial/tender-contract-get-documents.http', 'w') as self.app.file_obj:
response = self.app.get('/tenders/{}/contracts/{}/documents'.format(
self.tender_id, self.contract_id))
self.assertEqual(response.status, '200 OK')

with open('docs/source/tutorial/tender-contract-upload-second-document.http', 'w') as self.app.file_obj:
response = self.app.post('/tenders/{}/contracts/{}/documents'.format(
self.tender_id, self.contract_id), upload_files=[('file', 'contract_second_document.doc', 'content')])
self.assertEqual(response.status, '201 Created')

with open('docs/source/tutorial/tender-contract-get-documents-again.http', 'w') as self.app.file_obj:
response = self.app.get('/tenders/{}/contracts/{}/documents'.format(
self.tender_id, self.contract_id))
self.assertEqual(response.status, '200 OK')

#### Contract signing
#

tender = self.db.get(self.tender_id)
for i in tender.get('awards', []):
Expand All @@ -245,10 +291,9 @@ def test_docs(self):

with open('docs/source/tutorial/tender-contract-sign.http', 'w') as self.app.file_obj:
response = self.app.patch_json('/tenders/{}/contracts/{}?acc_token={}'.format(
self.tender_id, contract_id, owner_token), {'data': {'status': 'active'}})
self.tender_id, self.contract_id, owner_token), {'data': {'status': 'active'}})
self.assertEqual(response.status, '200 OK')


#### Preparing the cancellation request
#

Expand All @@ -272,7 +317,7 @@ def test_docs(self):

with open('docs/source/tutorial/patch-cancellation.http', 'w') as self.app.file_obj:
response = self.app.patch_json('/tenders/{}/cancellations/{}/documents/{}?acc_token={}'.format(
self.tender_id, cancellation_id, cancellation_doc_id, owner_token), {'data': {"description": 'Changed description'}} )
self.tender_id, cancellation_id, cancellation_doc_id, owner_token), {'data': {"description": 'Changed description'}})
self.assertEqual(response.status, '200 OK')

with open('docs/source/tutorial/update-cancellation-doc.http', 'w') as self.app.file_obj:
Expand All @@ -285,5 +330,5 @@ def test_docs(self):

with open('docs/source/tutorial/active-cancellation.http', 'w') as self.app.file_obj:
response = self.app.patch_json('/tenders/{}/cancellations/{}?acc_token={}'.format(
self.tender_id, cancellation_id, owner_token), {"data":{"status":"active"}})
self.tender_id, cancellation_id, owner_token), {"data": {"status": "active"}})
self.assertEqual(response.status, '200 OK')
54 changes: 54 additions & 0 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,34 @@ Procuring entity can register supplier information:
:code:


Uploading award documentation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can upload award documents only before confirm awarding decision. Let's add award document:

.. include:: tutorial/tender-award-upload-document.http
:code:

`201 Created` response code and `Location` header confirm document added.

Let's see the list of award documents:

.. include:: tutorial/tender-award-get-documents.http
:code:

We can add another award document:

.. include:: tutorial/tender-award-upload-second-document.http
:code:

`201 Created` response code and `Location` header confirm second document added.

Let's see the list of all uploaded award documents:

.. include:: tutorial/tender-award-get-documents-again.http
:code:


Award confirmation
~~~~~~~~~~~~~~~~~~

Expand All @@ -79,6 +107,32 @@ Procuring entity can confirm awarding decision:
.. include:: tutorial/tender-award-approve.http
:code:

Uploading contract documentation
--------------------------------

Contract documents can be uploaded only up until conclusion of the agreement. Let's add contract document:

.. include:: tutorial/tender-contract-upload-document.http
:code:

`201 Created` response code and `Location` header confirm document added.

Let's see the list of contract documents:

.. include:: tutorial/tender-contract-get-documents.http
:code:

We can add another contract document:

.. include:: tutorial/tender-contract-upload-second-document.http
:code:

`201 Created` response code and `Location` header confirm second document added.

Let's see the list of all uploaded contract documents:

.. include:: tutorial/tender-contract-get-documents-again.http
:code:

Contract signing
----------------
Expand Down
22 changes: 11 additions & 11 deletions docs/source/tutorial/active-cancellation.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PATCH /api/0.12/tenders/cf84223ef83043aba90dbc516294807c/cancellations/a6b7f1c425a44945b49fb828151043de?acc_token=a8651945689d4863b61d3fae00208858 HTTP/1.0
PATCH /api/0.12/tenders/76529955690a42148f6e59caf52f57bc/cancellations/313d5b14735d4f25a5521292b84ba610?acc_token=f8cd982c5857444aa6e633ef747434e2 HTTP/1.0
Authorization: Basic dG9rZW46
Content-Length: 30
Content-Type: application/json
Expand All @@ -19,27 +19,27 @@ Content-Type: application/json; charset=UTF-8
{
"description": "Changed description",
"title": "Notice.pdf",
"url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/cf84223ef83043aba90dbc516294807c/cancellations/a6b7f1c425a44945b49fb828151043de/documents/676c369595ce4bf9ab4986320316ab14?download=65700b25d82d4d1e9ae4f28af019a56a",
"url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/76529955690a42148f6e59caf52f57bc/cancellations/313d5b14735d4f25a5521292b84ba610/documents/9f9aaf9620c54413999b0943873a16ce?download=663eff17fe654295b71f338e25b6c9c8",
"format": "application/pdf",
"documentOf": "tender",
"datePublished": "2016-01-28T17:19:58.798468+02:00",
"id": "676c369595ce4bf9ab4986320316ab14",
"dateModified": "2016-01-28T17:19:58.798506+02:00"
"datePublished": "2016-02-08T15:42:37.247735+02:00",
"id": "9f9aaf9620c54413999b0943873a16ce",
"dateModified": "2016-02-08T15:42:37.247781+02:00"
},
{
"title": "Notice-2.pdf",
"url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/cf84223ef83043aba90dbc516294807c/cancellations/a6b7f1c425a44945b49fb828151043de/documents/676c369595ce4bf9ab4986320316ab14?download=26eefb18eb51473396a0afa203696713",
"url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/76529955690a42148f6e59caf52f57bc/cancellations/313d5b14735d4f25a5521292b84ba610/documents/9f9aaf9620c54413999b0943873a16ce?download=4172aa9701e44f018329b3a75467868c",
"format": "application/pdf",
"documentOf": "tender",
"datePublished": "2016-01-28T17:19:58.798468+02:00",
"id": "676c369595ce4bf9ab4986320316ab14",
"dateModified": "2016-01-28T17:19:59.072190+02:00"
"datePublished": "2016-02-08T15:42:37.247735+02:00",
"id": "9f9aaf9620c54413999b0943873a16ce",
"dateModified": "2016-02-08T15:42:37.698863+02:00"
}
],
"reason": "cancellation reason",
"date": "2016-01-28T17:19:58.703772+02:00",
"date": "2016-02-08T15:42:37.043115+02:00",
"cancellationOf": "tender",
"id": "a6b7f1c425a44945b49fb828151043de"
"id": "313d5b14735d4f25a5521292b84ba610"
}
}

10 changes: 5 additions & 5 deletions docs/source/tutorial/create-tender-procuringEntity.http
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ Host: api-sandbox.openprocurement.org

Response: 201 Created
Content-Type: application/json; charset=UTF-8
Location: http://api-sandbox.openprocurement.org/api/0.12/tenders/cf84223ef83043aba90dbc516294807c
Location: http://api-sandbox.openprocurement.org/api/0.12/tenders/76529955690a42148f6e59caf52f57bc
{
"access": {
"token": "a8651945689d4863b61d3fae00208858"
"token": "f8cd982c5857444aa6e633ef747434e2"
},
"data": {
"procurementMethod": "limited",
Expand Down Expand Up @@ -95,10 +95,10 @@ Location: http://api-sandbox.openprocurement.org/api/0.12/tenders/cf84223ef83043
"amount": 500000.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2016-01-28T17:19:57.396524+02:00",
"tenderID": "UA-2016-01-28-000001",
"dateModified": "2016-02-08T15:42:34.107192+02:00",
"tenderID": "UA-2016-02-08-000001",
"owner": "broker",
"id": "cf84223ef83043aba90dbc516294807c",
"id": "76529955690a42148f6e59caf52f57bc",
"procuringEntity": {
"contactPoint": {
"url": "http://sch10.edu.vn.ua/",
Expand Down
10 changes: 5 additions & 5 deletions docs/source/tutorial/patch-cancellation.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PATCH /api/0.12/tenders/cf84223ef83043aba90dbc516294807c/cancellations/a6b7f1c425a44945b49fb828151043de/documents/676c369595ce4bf9ab4986320316ab14?acc_token=a8651945689d4863b61d3fae00208858 HTTP/1.0
PATCH /api/0.12/tenders/76529955690a42148f6e59caf52f57bc/cancellations/313d5b14735d4f25a5521292b84ba610/documents/9f9aaf9620c54413999b0943873a16ce?acc_token=f8cd982c5857444aa6e633ef747434e2 HTTP/1.0
Authorization: Basic dG9rZW46
Content-Length: 48
Content-Type: application/json
Expand All @@ -16,12 +16,12 @@ Content-Type: application/json; charset=UTF-8
"data": {
"description": "Changed description",
"title": "Notice.pdf",
"url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/cf84223ef83043aba90dbc516294807c/cancellations/a6b7f1c425a44945b49fb828151043de/documents/676c369595ce4bf9ab4986320316ab14?download=65700b25d82d4d1e9ae4f28af019a56a",
"url": "http://api-sandbox.openprocurement.org/api/0.12/tenders/76529955690a42148f6e59caf52f57bc/cancellations/313d5b14735d4f25a5521292b84ba610/documents/9f9aaf9620c54413999b0943873a16ce?download=663eff17fe654295b71f338e25b6c9c8",
"format": "application/pdf",
"documentOf": "tender",
"datePublished": "2016-01-28T17:19:58.798468+02:00",
"id": "676c369595ce4bf9ab4986320316ab14",
"dateModified": "2016-01-28T17:19:58.798506+02:00"
"datePublished": "2016-02-08T15:42:37.247735+02:00",
"id": "9f9aaf9620c54413999b0943873a16ce",
"dateModified": "2016-02-08T15:42:37.247781+02:00"
}
}

8 changes: 4 additions & 4 deletions docs/source/tutorial/patch-items-value-periods.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PATCH /api/0.12/tenders/cf84223ef83043aba90dbc516294807c?acc_token=a8651945689d4863b61d3fae00208858 HTTP/1.0
PATCH /api/0.12/tenders/76529955690a42148f6e59caf52f57bc?acc_token=f8cd982c5857444aa6e633ef747434e2 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 80
Content-Type: application/json
Expand Down Expand Up @@ -54,10 +54,10 @@ Content-Type: application/json; charset=UTF-8
"amount": 500000.0,
"valueAddedTaxIncluded": true
},
"dateModified": "2016-01-28T17:19:57.602399+02:00",
"tenderID": "UA-2016-01-28-000001",
"dateModified": "2016-02-08T15:42:34.374328+02:00",
"tenderID": "UA-2016-02-08-000001",
"owner": "broker",
"id": "cf84223ef83043aba90dbc516294807c",
"id": "76529955690a42148f6e59caf52f57bc",
"procuringEntity": {
"contactPoint": {
"url": "http://sch10.edu.vn.ua/",
Expand Down
8 changes: 4 additions & 4 deletions docs/source/tutorial/prepare-cancellation.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
POST /api/0.12/tenders/cf84223ef83043aba90dbc516294807c/cancellations?acc_token=a8651945689d4863b61d3fae00208858 HTTP/1.0
POST /api/0.12/tenders/76529955690a42148f6e59caf52f57bc/cancellations?acc_token=f8cd982c5857444aa6e633ef747434e2 HTTP/1.0
Authorization: Basic dG9rZW46
Content-Length: 43
Content-Type: application/json
Expand All @@ -12,14 +12,14 @@ Host: api-sandbox.openprocurement.org

Response: 201 Created
Content-Type: application/json; charset=UTF-8
Location: http://api-sandbox.openprocurement.org/api/0.12/tenders/cf84223ef83043aba90dbc516294807c/cancellations/a6b7f1c425a44945b49fb828151043de
Location: http://api-sandbox.openprocurement.org/api/0.12/tenders/76529955690a42148f6e59caf52f57bc/cancellations/313d5b14735d4f25a5521292b84ba610
{
"data": {
"date": "2016-01-28T17:19:58.703772+02:00",
"date": "2016-02-08T15:42:37.043115+02:00",
"status": "pending",
"reason": "cancellation reason",
"cancellationOf": "tender",
"id": "a6b7f1c425a44945b49fb828151043de"
"id": "313d5b14735d4f25a5521292b84ba610"
}
}

0 comments on commit 2f10517

Please sign in to comment.