From 8304add63e3ad2310d203ceea81060d96f4c13fb Mon Sep 17 00:00:00 2001 From: "Ian H. Pittwood" Date: Mon, 22 Jul 2019 12:02:16 -0500 Subject: [PATCH] Add tests for site processor init This change adds a couple tests for init in Spyglass' site processor class, bringing total test coverage up to the goal of 90%. Change-Id: I81c1dfdf2a9d65589d961451401802621058a9f2 --- .../site_processors/test_site_processor.py | 25 +++++++++++++++++++ tox.ini | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/unit/site_processors/test_site_processor.py b/tests/unit/site_processors/test_site_processor.py index 8e6ea55..a4b2b19 100644 --- a/tests/unit/site_processors/test_site_processor.py +++ b/tests/unit/site_processors/test_site_processor.py @@ -61,6 +61,31 @@ class TestSiteProcessor(unittest.TestCase): site_type:{{ undefined_param }} ...""") + @mock.patch( + 'spyglass.data_extractor.models.SiteDocumentData', + spec=models.SiteDocumentData) + def test___init__(self, SiteDocumentData): + site_data = SiteDocumentData() + _out_dir = mkdtemp() + obj = SiteProcessor(site_data, _out_dir, force_write=False) + self.assertEqual(site_data, obj.site_data) + self.assertEqual(_out_dir, obj.manifest_dir) + self.assertFalse(obj.force_write) + + @mock.patch( + 'spyglass.site_processors.site_processor.site_document_data_factory', + autospec=True, + return_value='success') + def test___init___use_site_document_data_factory( + self, site_document_data_factory): + site_data = {} + _out_dir = mkdtemp() + obj = SiteProcessor(site_data, _out_dir, force_write=False) + site_document_data_factory.assert_called_once_with(site_data) + self.assertEqual('success', obj.site_data) + self.assertEqual(_out_dir, obj.manifest_dir) + self.assertFalse(obj.force_write) + @mock.patch( 'spyglass.data_extractor.models.SiteDocumentData', spec=models.SiteDocumentData) diff --git a/tox.ini b/tox.ini index 2a308b1..e2cc353 100644 --- a/tox.ini +++ b/tox.ini @@ -89,6 +89,6 @@ commands = pipenv install --dev bash -c 'PATH=$PATH:~/.local/bin; pytest --cov=spyglass \ --cov-report html:cover --cov-report xml:cover/coverage.xml \ - --cov-report term --cov-fail-under 84 tests/' + --cov-report term --cov-fail-under 88 tests/' whitelist_externals = bash