Permalink
Browse files

deduplicating ddoc check & retrieve code in tests

  • Loading branch information...
1 parent 912d149 commit db38e6d8a3ecead8acef977a33025824561b766a @BigBlueHat BigBlueHat committed Dec 16, 2013
Showing with 13 additions and 21 deletions.
  1. +13 −21 tests/test_cli.py
View
@@ -47,6 +47,16 @@ def _make_testapp(self):
testapp_path = os.path.join(os.path.dirname(__file__), 'testapp')
shutil.copytree(testapp_path, self.app_dir)
+ def _retrieve_ddoc(self):
+ # any design doc created ?
+ design_doc = None
+ try:
+ design_doc = self.db.open_doc('_design/my-app')
+ except ResourceNotFound:
+ pass
+ self.assertIsNotNone(design_doc)
+ return design_doc
+
def testGenerate(self):
os.chdir(self.tempdir)
(child_stdin, child_stdout, child_stderr) = popen3("%s generate my-app"
@@ -71,13 +81,7 @@ def testPush(self):
(child_stdin, child_stdout, child_stderr) = \
popen3("%s push -v my-app couchapp-test" % self.cmd)
- # any design doc created ?
- design_doc = None
- try:
- design_doc = self.db.open_doc('_design/my-app')
- except ResourceNotFound:
- pass
- self.assertIsNotNone(design_doc)
+ design_doc = self._retrieve_ddoc()
# should create view
self.assertIn('function', design_doc['views']['example']['map'])
@@ -114,13 +118,7 @@ def testPushNoAtomic(self):
(child_stdin, child_stdout, child_stderr) = \
popen3("%s push --no-atomic my-app couchapp-test" % self.cmd)
- # any design doc created ?
- design_doc = None
- try:
- design_doc = self.db.open_doc('_design/my-app')
- except ResourceNotFound:
- pass
- self.assertIsNotNone(design_doc)
+ design_doc = self._retrieve_ddoc()
# there are 3 revisions (1 doc creation + 2 attachments)
self.assertTrue(design_doc['_rev'].startswith('3-'))
@@ -158,13 +156,7 @@ def testClone(self):
(child_stdin, child_stdout, child_stderr) = \
popen3("%s push -v my-app couchapp-test" % self.cmd)
- # any design doc created ?
- design_doc = None
- try:
- design_doc = self.db.open_doc('_design/my-app')
- except ResourceNotFound:
- pass
- self.assertIsNotNone(design_doc)
+ design_doc = self._retrieve_ddoc()
app_dir = os.path.join(self.tempdir, "couchapp-test")

0 comments on commit db38e6d

Please sign in to comment.