nasg/tests.py
2018-12-01 10:45:27 +00:00

54 lines
1.7 KiB
Python

import unittest
import pandoc
import exiftool
import nasg
import os
import json
class TestNASG(unittest.TestCase):
def test_url2slug(self):
i = 'http://boffosocko.com/2017/10/28/content-bloat-privacy-archives-peter-molnar/'
o = 'boffosockocom20171028content-bloat-privacy-archives-peter-molnar'
self.assertEqual(nasg.url2slug(i), o)
class TestSingular(unittest.TestCase):
singular = nasg.Singular('tests/index.md')
# TODO: WTF?
#def test_category(self):
#print(self.singular.category)
#self.assertEqual(self.singular.category, 'tests')
#def test_files(self):
#self.assertEqual(
#self.singular.files,
#['/home/pemolnar/Projects/petermolnar.net/nasg/tests/tests.jpg']
def test_is_photo(self):
self.assertTrue(self.singular.is_photo)
def test_is_front(self):
self.assertFalse(self.singular.is_front)
def test_singular_tags(self):
self.assertEqual(
self.singular.tags,
['Llyn Idwal', 'winter', 'spring', 'cloudy', 'Snowdonia', 'mountain', 'clouds', 'lake', 'mountains', 'snow', 'Wales', 'water']
)
class TestExiftool(unittest.TestCase):
def test_exiftool(self):
with open('tests/.tests.jpg.json', 'rt') as expected:
o = json.loads(expected.read())
self.assertEqual(exiftool.Exif('tests/tests.jpg'), o)
class TestPandoc(unittest.TestCase):
def test_pandoc(self):
i = '_this_ is a **test** string for [pandoc](https://pandoc.org)'
o = '<p><em>this</em> is a <strong>test</strong> string for <a href="https://pandoc.org">pandoc</a></p>'
self.assertEqual(pandoc.Pandoc(i), o)
if __name__ == '__main__':
unittest.main()