def test_read_mmd_str(mock_koji_session, mock_koji_pathinfo): mmd_str, mmd_dict = get_test_mmd_str_and_dict() binfo = {'extra': {'typeinfo': {'module': {'modulemd_str': mmd_str}}}} mock_koji_session.return_value.getBuild.return_value = binfo mock_options = MagicMock(koji=True, source="build_nvr:modulemd.src.txt") with patch('os.path.isfile', return_value=True): processor = BaseProcessor(mock_options) processor.source_file = os.path.join(MODULES_PATH, "modulemd.src.txt") processor.read_source_file() assert_that(processor.package, equal_to(mmd_dict['name'])) assert_that(processor.version, equal_to(mmd_dict['stream'])) assert_that(processor.release, equal_to(str(mmd_dict['version']) + '.' + mmd_dict['context'])) assert_that(processor.summary, equal_to(mmd_dict['summary']))
def test_git_url_module(mock_koji_session, mock_koji_pathinfo): mmd_str, mmd_dict = get_test_mmd_str_and_dict() binfo = {'extra': {'typeinfo': {'module': {'modulemd_str': mmd_str}}}} mock_koji_session.return_value.getBuild.return_value = binfo mock_options = MagicMock(koji=True, source="build_nvr:modulemd.src.txt", config=CONFIG_DEFAULTS) with patch('os.path.isfile', return_value=True): processor = BaseProcessor(mock_options) processor.source_file = os.path.join(MODULES_PATH, "modulemd.src.txt") processor.read_source_file() git_push_url = processor.git_push_url() git_fetch_url = processor.git_fetch_url() assert_that(git_push_url, equal_to(processor.options.config['git_push_url_module'] % {'package': mmd_dict['name']})) assert_that(git_fetch_url, equal_to(processor.options.config['git_push_url_module'] % {'package': mmd_dict['name']}))