Skip to content

Commit

Permalink
Merge pull request #29 from gorserg/fix_tests_memory
Browse files Browse the repository at this point in the history
Fix memory leak in tests
  • Loading branch information
kroman0 committed Jul 21, 2016
2 parents fc7ddab + 8da16a4 commit 43402c9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
8 changes: 4 additions & 4 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ find-links = http://op:x9W3jZ@dist.quintagroup.com/op/
auto-checkout = openprocurement.api openprocurement.tender.openua openprocurement.tender.openeu

[sources]
openprocurement.tender.openua = git https://github.com/openprocurement/openprocurement.tender.openua.git
openprocurement.tender.openeu = git https://github.com/openprocurement/openprocurement.tender.openeu.git
openprocurement.api = git https://github.com/openprocurement/openprocurement.api.git
openprocurement.tender.openua = git https://github.com/openprocurement/openprocurement.tender.openua.git branch=production
openprocurement.tender.openeu = git https://github.com/openprocurement/openprocurement.tender.openeu.git branch=production
openprocurement.api = git https://github.com/openprocurement/openprocurement.api.git branch=extend_acl_for_cd

[test]
recipe = zc.recipe.egg:scripts
dependent-scripts = true
eggs =
openprocurement.tender.competitivedialogue [test]
nose
nose
2 changes: 2 additions & 0 deletions openprocurement/tender/competitivedialogue/tests/auth.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ reviewer = reviewer
[admins]
test = token

[competitive_dialogue]
competitive_dialogue = competitive_dialogue,c
28 changes: 21 additions & 7 deletions openprocurement/tender/competitivedialogue/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
test_bids,
test_bids as test_bids_eu)
from openprocurement.tender.competitivedialogue.models import CD_EU_TYPE, CD_UA_TYPE
from openprocurement.api.design import sync_design
from openprocurement.api.tests.base import PrefixedRequestClass, test_organization
from openprocurement.tender.openua.tests.base import (test_tender_data as base_test_tender_data_ua, BaseTenderWebTest)

now = datetime.now()
test_tender_data_eu = deepcopy(base_test_tender_data_eu)
Expand Down Expand Up @@ -47,6 +50,14 @@ class BaseCompetitiveDialogWebTest(BaseTenderWebTest):
initial_lots = None
initial_auth = None

@classmethod
def setUpClass(cls):
cls.app = webtest.TestApp("config:tests.ini", relative_to=os.path.dirname(__file__))
cls.app.RequestClass = PrefixedRequestClass
cls.couchdb_server = cls.app.app.registry.couchdb_server
cls.db = cls.app.app.registry.db
cls.db_name = cls.db.name

def go_to_enquiryPeriod_end(self):
now = get_now()
self.set_status('active.tendering', {
Expand All @@ -61,18 +72,19 @@ def go_to_enquiryPeriod_end(self):
})

def setUp(self):
self.app = webtest.TestApp(
"config:tests.ini", relative_to=os.path.dirname(__file__))
self.app.RequestClass = PrefixedRequestClass
if self.initial_auth:
self.app.authorization = self.initial_auth
else:
self.app.authorization = ('Basic', ('token', ''))
self.couchdb_server = self.app.app.registry.couchdb_server
self.db = self.app.app.registry.db
self.app.authorization = ('Basic', ('broker', ''))

def tearDown(self):
del self.couchdb_server[self.db.name]
self.couchdb_server.delete(self.db_name)
self.couchdb_server.create(self.db_name)
db = self.couchdb_server[self.db_name]
# sync couchdb views
sync_design(db)
self.app.app.registry.db = db
self.db = self.app.app.registry.db

def check_chronograph(self):
authorization = self.app.authorization
Expand Down Expand Up @@ -368,6 +380,7 @@ class BaseCompetitiveDialogUAContentWebTest(BaseCompetitiveDialogUAWebTest):
initial_lots = None

def setUp(self):
self.app.authorization = ('Basic', ('broker', ''))
super(BaseCompetitiveDialogUAContentWebTest, self).setUp()
self.create_tender()

Expand All @@ -379,6 +392,7 @@ class BaseCompetitiveDialogEUContentWebTest(BaseCompetitiveDialogEUWebTest):
initial_lots = None

def setUp(self):
self.app.authorization = ('Basic', ('broker', ''))
super(BaseCompetitiveDialogEUContentWebTest, self).setUp()
self.create_tender()

Expand Down
3 changes: 2 additions & 1 deletion openprocurement/tender/competitivedialogue/tests/bid.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def test_create_tender_bidder(self):
'status': status}},
status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.json['errors'][0]['description'], "Bid can be added only with status: ['draft', 'pending'].")
self.assertEqual(response.json['errors'][0]['description'],
"Bid can be added only with status: ['draft', 'pending'].")

self.set_status('complete') # set tender status to complete

Expand Down

0 comments on commit 43402c9

Please sign in to comment.