Skip to content

Commit

Permalink
Test converter (#125)
Browse files Browse the repository at this point in the history
* Test converter

* Minor changes

* Minor change

* minor change

* Suggested changes

* minor change

* Update test_converter.py

* remove unwanted module

* Update test_converter.py

* minor change

* Minor changes

* Suggested change

* Suggested change

* minor error
  • Loading branch information
viskey98 authored and afeena committed May 16, 2018
1 parent fb417d1 commit 841af31
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import unittest
import os
import sys
import shutil
import json
from converter import Converter


class TestConverter(unittest.TestCase):
def setUp(self):
self.content = '<html><body></body></html>'
self.page_path = '/tmp/test/'
if not os.path.exists('/tmp/test/depth'):
os.makedirs('/tmp/test/depth')
self.hname1 = ""
self.hname2 = ""
with open(os.path.join(self.page_path, 'index.html'), 'w') as f:
f.write(self.content)
with open(os.path.join(self.page_path, 'depth/page.html'), 'w') as f:
f.write(self.content)
self.cnv = Converter()

def test_converter(self):
self.cnv.convert(self.page_path)
with open(os.path.join(self.page_path, 'meta.json')) as f:
s = json.load(f)
self.hname1 = s['index.html']['hash']
self.hname2 = s['depth/page.html']['hash']
assert(os.path.exists(self.page_path + self.hname1) and
os.path.exists(self.page_path + self.hname2))

def tearDown(self):
shutil.rmtree('/tmp/test')

0 comments on commit 841af31

Please sign in to comment.