def test___init___working_dir_exists(self, PublishMetadataStep, PublishContentStep, get_working_dir, super___init__, exists, makedirs, get_web_publish_dir, get_master_publish_dir, AtomicDirectoryPublishStep): """ Assert correct operation from the __init__() method when the working_dir does exist. """ repo = mock.MagicMock() publish_conduit = mock.MagicMock() config = mock.MagicMock() working_dir = os.path.join('/', 'some', 'working', 'dir') get_working_dir.return_value = working_dir publish_dir = os.path.join('/', 'some', 'web', 'publish', 'dir') get_web_publish_dir.return_value = publish_dir master_publish_dir = os.path.join('/', 'some', 'master', 'publish', 'dir') get_master_publish_dir.return_value = master_publish_dir p = steps.PythonPublisher(repo, publish_conduit, config) super___init__.assert_called_once_with( p, constants.PUBLISH_STEP_PUBLISHER, repo, publish_conduit, config) get_web_publish_dir.assert_called_once_with(repo, config) # os.path.exists should have been called once for working_dir. It also gets called for a lot # of locale stuff, so we'll need to filter those out. pulp_exists_calls = [ c for c in exists.mock_calls if 'locale' not in c[1][0] ] self.assertEqual(len(pulp_exists_calls), 1) self.assertEqual(pulp_exists_calls[0][1], (working_dir, )) self.assertEqual(makedirs.call_count, 0) AtomicDirectoryPublishStep.assert_called_once_with( working_dir, [(repo.id, publish_dir)], master_publish_dir, step_type=constants.PUBLISH_STEP_OVER_HTTP) self.assertEqual(AtomicDirectoryPublishStep.return_value.description, _('Making files available via web.')) self.assertEqual(len(p.children), 3) self.assertEqual( set(p.children), set([ AtomicDirectoryPublishStep.return_value, PublishContentStep.return_value, PublishMetadataStep.return_value ]))
def test___init___working_dir_does_not_exist( self, PublishMetadataStep, PublishContentStep, get_working_dir, super___init__, makedirs, get_web_publish_dir, get_master_publish_dir, AtomicDirectoryPublishStep): """ Assert correct operation from the __init__() method when the working_dir does not exist. """ repo = mock.MagicMock() publish_conduit = mock.MagicMock() config = mock.MagicMock() working_dir = os.path.join('/', 'some', 'working', 'dir') get_working_dir.return_value = working_dir publish_dir = os.path.join('/', 'some', 'web', 'publish', 'dir') get_web_publish_dir.return_value = publish_dir master_publish_dir = os.path.join('/', 'some', 'master', 'publish', 'dir') get_master_publish_dir.return_value = master_publish_dir p = steps.PythonPublisher(repo, publish_conduit, config) super___init__.assert_called_once_with( p, constants.PUBLISH_STEP_PUBLISHER, repo, publish_conduit, config) get_web_publish_dir.assert_called_once_with(repo, config) makedirs.assert_called_once_with(working_dir) AtomicDirectoryPublishStep.assert_called_once_with( working_dir, [(repo.id, publish_dir)], master_publish_dir, step_type=constants.PUBLISH_STEP_OVER_HTTP) self.assertEqual(AtomicDirectoryPublishStep.return_value.description, _('Making files available via web.')) self.assertEqual(len(p.children), 3) self.assertEqual( set(p.children), set([ AtomicDirectoryPublishStep.return_value, PublishContentStep.return_value, PublishMetadataStep.return_value ]))