all repos — nasg @ a57fac3b11a84fc4f7fac77a1fc0a4bc5b320de0

adding first set of tests
Peter Molnar hello@petermolnar.eu
Sat, 01 Dec 2018 10:45:27 +0000
commit

a57fac3b11a84fc4f7fac77a1fc0a4bc5b320de0

parent

de269ef39efa0a11f7fed59e7526f950efcfec30

4 files changed, 112 insertions(+), 0 deletions(-)

jump to
A 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 = '<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()
A tests/.tests.jpg.json

@@ -0,0 +1,29 @@

+{ + "Aperture": 11.0, + "Artist": "Peter Molnar", + "Copyright": "Copyright 2016 Peter Molnar <hello@petermolnar.eu> (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" +}
A 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