From 06371dfe9bb8f78a43b654401f72dae2eb925612 Mon Sep 17 00:00:00 2001 From: Sean Whalen Date: Thu, 4 Apr 2019 20:15:55 -0400 Subject: [PATCH] Expand test coverage --- .travis.yml | 3 +-- tests.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2b46bd..a1056f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,7 @@ script: - "cd docs" - "make html" - "cd .." - - "python tests.py" - - "coverage run tests.py" + - "coverage run tests.py" - "python setup.py install" - "parsedmarc -c ci.ini samples/aggregate/*" - "parsedmarc -c ci.ini samples/forensic/*" diff --git a/tests.py b/tests.py index 6d33a55..8f659ed 100644 --- a/tests.py +++ b/tests.py @@ -5,9 +5,28 @@ from glob import glob import json import parsedmarc +import parsedmarc.utils class Test(unittest.TestCase): + def testBase64Decoding(self): + """Test base64 decoding""" + # Example from Wikipedia Base64 article + b64_str = "YW55IGNhcm5hbCBwbGVhcw" + decoded_str = parsedmarc.utils.decode_base64(b64_str) + assert decoded_str == b"any carnal pleas" + + def testPSLDownload(self): + subdomain = "foo.example.com" + result = parsedmarc.utils.get_base_domain(subdomain, + use_fresh_psl=True) + assert result == "example.com" + + # Test PSL caching + result = parsedmarc.utils.get_base_domain(subdomain, + use_fresh_psl=True) + assert result == "example.com" + def testAggregateSamples(self): """Test sample aggregate/rua DMARC reports""" sample_paths = glob("samples/aggregate/*")