File size: 1,184 Bytes
3315103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import unittest
import os
import shutil
from pyhwp.html_converter import HwpToHtmlConverter

class TestHwpToHtml(unittest.TestCase):
    def setUp(self):
        self.test_dir = 'test_output'
        if not os.path.exists(self.test_dir):
            os.mkdir(self.test_dir)
        # Assuming we have a sample HWP file. If not, we might fail or need to mock.
        # For now, we'll verify the class structure and basic error handling.
        self.dummy_hwp = 'dummy.hwp'
        with open(self.dummy_hwp, 'w') as f:
             f.write('dummy content')

    def tearDown(self):
        if os.path.exists(self.test_dir):
            shutil.rmtree(self.test_dir)
        if os.path.exists(self.dummy_hwp):
            os.remove(self.dummy_hwp)

    def test_instantiation(self):
        converter = HwpToHtmlConverter(self.dummy_hwp)
        self.assertIsNotNone(converter)
        self.assertEqual(converter.hwp_file, self.dummy_hwp)

    def test_convert_file_not_found(self):
        converter = HwpToHtmlConverter('non_existent.hwp')
        with self.assertRaises(FileNotFoundError):
            converter.convert('output.html')

if __name__ == '__main__':
    unittest.main()