| 1 | from base import StaticSiteTestCase |
|---|
| 2 | from enpraxis.staticsite.utilities.interfaces import IStaticSiteUtility |
|---|
| 3 | from zope.component import getUtility |
|---|
| 4 | from os.path import join as os_join |
|---|
| 5 | from os.path import split as os_split |
|---|
| 6 | import Globals |
|---|
| 7 | import os |
|---|
| 8 | |
|---|
| 9 | class TestDeploy(StaticSiteTestCase): |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | def afterSetUp(self): |
|---|
| 13 | """ Create some dummy objects """ |
|---|
| 14 | import pdb; pdb.set_trace() |
|---|
| 15 | self.setRoles('Manager') |
|---|
| 16 | # self.folder = getattr(self.portal, 'test-folder', None) |
|---|
| 17 | # self.doc = self.folder.invokeFactory('Document', 'test-page') |
|---|
| 18 | # self.file = self.folder.invokeFactory('File', 'test-file') |
|---|
| 19 | # self.image = self.folder.invokeFactory('Image', 'test-image') |
|---|
| 20 | # os.chdir('tests') |
|---|
| 21 | # os.mkdir('tmp') |
|---|
| 22 | # os.chdir('tmp') |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | def testWriteFile(self): |
|---|
| 26 | """ Integration test for writing a file """ |
|---|
| 27 | import pdb; pdb.set_trace() |
|---|
| 28 | filepathlist =['test-folder','test-folder','test-file'] |
|---|
| 29 | ssutil = getUtility(IStaticSiteUtility) |
|---|
| 30 | file_path = '%s' %(os_join(filepathlist)) |
|---|
| 31 | fdata = '<html><test-page></test-page></html>' |
|---|
| 32 | # ssutil._writeFile(file_path, fdata) |
|---|
| 33 | # file = open(file_path, 'r') |
|---|
| 34 | # ndata = file.read() |
|---|
| 35 | # file.close() |
|---|
| 36 | # self.assertEqual(ndata, fdata) |
|---|
| 37 | # # Try writing data over the top |
|---|
| 38 | # fdata = '<html><test-doc></test-doc></html>' |
|---|
| 39 | # ssutil._writeFile(file_path, fdata) |
|---|
| 40 | # file = open(file_path, 'r') |
|---|
| 41 | # ndata = file.read() |
|---|
| 42 | # file.close() |
|---|
| 43 | # self.assertEqual(ndata, fdata) |
|---|
| 44 | |
|---|
| 45 | def testCreateDirectory(self): |
|---|
| 46 | """ Integration test for _createDirectory method """ |
|---|
| 47 | fldrpathlist = ['test-folder','test-folder-2'] |
|---|
| 48 | ssutil = getUtility(IStaticSiteUtility) |
|---|
| 49 | folder_path = '%s' %(os_join(fldrpathlist)) |
|---|
| 50 | # ssutil._createDirectory(folder_path) |
|---|
| 51 | # # Run again to verify that folder can be overwritten |
|---|
| 52 | # ssutil._createDirectory(folder_path) |
|---|
| 53 | |
|---|
| 54 | def testGetObjPath(self): |
|---|
| 55 | """ Integration test for _getObjPath method """ |
|---|
| 56 | ssutil = getUtility(IStaticSiteUtility) |
|---|
| 57 | filepathlist =['test-folder','test-folder'] |
|---|
| 58 | url = 'http://localhost:8080/site/test-folder/test-file' |
|---|
| 59 | portal_url = 'http://localhost:8080/site' |
|---|
| 60 | dpath = ssutil._getObjPath(url, portal_url, os_join(filepathlist)) |
|---|
| 61 | self.assertEqual(dpath, dpath) |
|---|
| 62 | |
|---|
| 63 | def beforeTearDown(self): |
|---|
| 64 | """ Remove the tmp directory inside tests directory """ |
|---|
| 65 | # os.rmdir('tmp') |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | def test_suite(): |
|---|
| 70 | from unittest import TestSuite, makeSuite |
|---|
| 71 | suite = TestSuite() |
|---|
| 72 | suite.addTest(makeSuite(TestDeploy)) |
|---|
| 73 | return suite |
|---|