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
This commit is contained in:
Ian H. Pittwood 2019-07-22 12:02:16 -05:00
parent 4e2de1dae1
commit 8304add63e
2 changed files with 26 additions and 1 deletions

View File

@ -61,6 +61,31 @@ class TestSiteProcessor(unittest.TestCase):
site_type:{{ undefined_param }} 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( @mock.patch(
'spyglass.data_extractor.models.SiteDocumentData', 'spyglass.data_extractor.models.SiteDocumentData',
spec=models.SiteDocumentData) spec=models.SiteDocumentData)

View File

@ -89,6 +89,6 @@ commands =
pipenv install --dev pipenv install --dev
bash -c 'PATH=$PATH:~/.local/bin; pytest --cov=spyglass \ bash -c 'PATH=$PATH:~/.local/bin; pytest --cov=spyglass \
--cov-report html:cover --cov-report xml:cover/coverage.xml \ --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 = whitelist_externals =
bash bash