diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..d657a64 --- /dev/null +++ b/tests.py @@ -0,0 +1,54 @@ +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 = '

this is a test string for pandoc

' + self.assertEqual(pandoc.Pandoc(i), o) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/.tests.jpg.json b/tests/.tests.jpg.json new file mode 100644 index 0000000..292c8f8 --- /dev/null +++ b/tests/.tests.jpg.json @@ -0,0 +1,29 @@ +{ + "Aperture": 11.0, + "Artist": "Peter Molnar", + "Copyright": "Copyright 2016 Peter Molnar (https://petermolnar.net), CC BY-NC-ND 4.0", + "CreateDate": "2016-05-01T00:08:24+00:00", + "DateTimeOriginal": "2016-05-01T00:08:24+00:00", + "Description": "One can always wish for the perfect weather, yet most of the times, it remains a wish. Not this time.\n\nThere is a National Trust recommendation to visit Llyn Idwal, which Nora[^1] spotted, and they were right about the place: it's magnificent. We really weren't expecting snow on the mountains in May, but that, combined with the clouds and the late afternoon sunshine was just perfect.\n\nI cropped the image, but apart from that, it really looked like this. No edits, no nothing.\n\n[^1]: https://norahamucska.eu", + "ExposureTime": "1/320", + "FNumber": 11.0, + "FOV": "67.4 deg", + "FileName": "llyn-idwal.jpg", + "FileSize": 29123, + "FileType": "JPEG", + "FocalLength": "18.0 mm", + "FocalLengthIn35mmFormat": "27 mm", + "GPSLatitude": 53.115584, + "GPSLongitude": -4.030248, + "Headline": "Llyn Idwal", + "HierarchicalSubject": "Llyn Idwal", + "ISO": 160, + "ImageHeight": 139, + "ImageWidth": 256, + "LensID": "HD PENTAX-DA 16-85mm F3.5-5.6 ED DC WR", + "MIMEType": "image/jpeg", + "Model": "PENTAX K-5 II s", + "ModifyDate": "2016-05-01T00:08:24+00:00", + "ReleaseDate": "2016-07-23T09:00:23+00:00", + "SourceFile": "tests/llyn-idwal.jpg" +} \ No newline at end of file diff --git a/tests/index.md b/tests/index.md new file mode 100644 index 0000000..f38c54c --- /dev/null +++ b/tests/index.md @@ -0,0 +1,29 @@ +--- +GPSLatitude: 53.115584 +GPSLongitude: -4.030248 +published: 2016-07-23T09:00:23+0000 +tags: +- Llyn Idwal +- winter +- spring +- cloudy +- Snowdonia +- mountain +- clouds +- lake +- mountains +- snow +- Wales +- water +title: Llyn Idwal +--- + +![](tests.jpg) + +One can always wish for the perfect weather, yet most of the times, it remains a wish. Not this time. + +There is a National Trust recommendation to visit Llyn Idwal, which Nora[^1] spotted, and they were right about the place: it's magnificent. We really weren't expecting snow on the mountains in May, but that, combined with the clouds and the late afternoon sunshine was just perfect. + +I cropped the image, but apart from that, it really looked like this. No edits, no nothing. + +[^1]: https://norahamucska.eu diff --git a/tests/tests.jpg b/tests/tests.jpg new file mode 100644 index 0000000..ad40d36 Binary files /dev/null and b/tests/tests.jpg differ