X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/80a2c67a898b06c9c28bda89d7aa012676c2a23a..8d490fc7810e0052bad3414b445b24276bbfca63:/apps/api/tests/__init__.py?ds=sidebyside diff --git a/apps/api/tests/__init__.py b/apps/api/tests/__init__.py index acf92f5c..c5d79e70 100644 --- a/apps/api/tests/__init__.py +++ b/apps/api/tests/__init__.py @@ -19,6 +19,7 @@ def temprepo(name): def decorator(func): + @wraps(func) def decorated(self, *args, **kwargs): clean = False @@ -31,10 +32,11 @@ def temprepo(name): finally: if not clean and self.response: print "RESULT", func.__name__, ">>>" - print self.response + print self.response.content print "<<<" - - # shutil.rmtree(temp, True) + else: + shutil.rmtree(temp, True) + settings.REPOSITORY_PATH = '' return decorated @@ -103,8 +105,8 @@ class SimpleTest(TestCase): self.assert_json_response({ # u'latest_rev': u'f94a263812dbe46a3a13d5209bb119988d0078d5', u'documents': [ - {u'url': u'/api/documents/sample', u'name': u'sample'}, - {u'url': u'/api/documents/sample_pl', u'name': u'sample_pl'} + {u'url': u'/api/documents/sample', u'name': u'sample', u'parts': []}, + {u'url': u'/api/documents/sample_pl', u'name': u'sample_pl', u'parts': []} ], }) @@ -140,24 +142,27 @@ class SimpleTest(TestCase): self.response = self.client.get(resp['text_url']) self.assertEqual(self.response.status_code, 200) self.assertEqual(self.response.content, "Ala ma kota\n") -# -# -# @temprepo('simple') -# def test_document_text_update(self): -# self.assertTrue(self.client.login(username='admin', password='admin')) -# TEXT = u"Ala ma kota i psa" -# -# self.response = self.client.put( \ -# reverse("doctext_view", args=['testfile']), {'contents': TEXT }) -# self.assertEqual(self.response.status_code, 200) -# -# self.response = self.client.get( \ -# reverse("doctext_view", args=['testfile']) ) -# self.assertEqual(self.response.status_code, 200) -# self.assertEqual(self.response.content, TEXT) + + + @temprepo('simple') + def test_document_text_save(self): + self.assertTrue(self.client.login(username='admin', password='admin')) + TEXT = u"Ala ma kota i psa" + + self.response = self.client.get( + reverse("document_view", args=['sample']) ) + + resp = self.assert_json_response() + + self.response = self.client.post(resp['text_url'], { + 'revision': resp['user_revision'] ,'contents': TEXT }) + result = self.assert_json_response(must_have={u'document': u'sample'} ) + + #self.response = self.client.get(result['url']) + #self.assertEqual(self.response.content, TEXT) def assert_json_response(self, must_have={}, exclude=[], code=200): - self.assertEqual(self.response.status_code, code) + self.assertEqual(self.response.status_code, code) result = json.loads(self.response.content) for (k,v) in must_have.items():