def test_configured_publish_dir(self, mock_open, mock_find): mock_find.return_value = [ {'repo_id': 'repo1', 'config': {constants.CONFIG_HTTP_DIR: '/var/lib/pulp/published/puppet/foo'}} ] releases.get_repo_data(['repo1']) mock_open.assert_called_once_with( '/var/lib/pulp/published/puppet/foo/repo1/.dependency_db', 'r')
def test_db_open_error(self, mock_open, mock_find, mock_ctx): mock_ctx.protocol = 'http' mock_find.return_value = [{'repo_id':'repo1', 'config':{}}] mock_open.side_effect = gdbm.error result = releases.get_repo_data(['repo1']) self.assertEqual(result, {}) mock_open.assert_called_once_with('/var/www/pulp_puppet/http/repos/repo1/.dependency_db', 'r')
def test_single_repo(self, mock_open, mock_find, mock_ctx): mock_ctx.protocol = 'http' mock_find.return_value = [{'repo_id':'repo1', 'config':{}}] result = releases.get_repo_data(['repo1']) self.assertTrue(isinstance(result, dict)) self.assertEqual(result.keys(), ['repo1']) self.assertEqual(result['repo1']['db'], mock_open.return_value) mock_open.assert_called_once_with('/var/www/pulp_puppet/http/repos/repo1/.dependency_db', 'r')
def test_db_open_error(self, mock_open, mock_find, mock_ctx): mock_ctx.protocol = 'http' mock_find.return_value = [{'repo_id':'repo1', 'config':{}}] mock_open.side_effect = gdbm.error result = releases.get_repo_data(['repo1']) self.assertEqual(result, {}) mock_open.assert_called_once_with('/var/lib/pulp/published/puppet/http/repos/repo1/.dependency_db', 'r')
def test_configured_publish_dir(self, mock_open, mock_find, mock_ctx): mock_ctx.protocol = 'http' mock_find.return_value = [ {'repo_id':'repo1', 'config':{constants.CONFIG_HTTP_DIR: '/var/lib/pulp/published/puppet/foo'}} ] result = releases.get_repo_data(['repo1']) mock_open.assert_called_once_with('/var/lib/pulp/published/puppet/foo/repo1/.dependency_db', 'r')
def test_multiple_repos(self, mock_open, mock_find): mock_find.return_value = [ {'repo_id':'repo1', 'config':{}}, {'repo_id':'repo2', 'config':{}} ] result = releases.get_repo_data(['repo1', 'repo2']) self.assertTrue('repo1' in result) self.assertTrue('repo2' in result)
def test_multiple_repos(self, mock_open, mock_find, mock_ctx): mock_ctx.protocol = 'http' mock_find.return_value = [ {'repo_id':'repo1', 'config':{}}, {'repo_id':'repo2', 'config':{}} ] result = releases.get_repo_data(['repo1', 'repo2']) self.assertTrue('repo1' in result) self.assertTrue('repo2' in result)
def test_single_repo(self, mock_open, mock_find, mock_ctx): mock_ctx.protocol = 'http' mock_find.return_value = [{'repo_id':'repo1', 'config':{}}] result = releases.get_repo_data(['repo1']) self.assertTrue(isinstance(result, dict)) self.assertEqual(result.keys(), ['repo1']) self.assertEqual(result['repo1']['db'], mock_open.return_value) mock_open.assert_called_once_with('/var/lib/pulp/published/puppet/http/repos/repo1/.dependency_db', 'r')