Skip to content

Commit 88732d5

Browse files
committed
test expected types and missing YAML
1 parent b10dd01 commit 88732d5

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/somef/header_analysis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ def extract_categories(repo_data: str, repository_metadata: Result) -> Tuple[Res
451451
'ParentHeader': constants.PROP_PARENT_HEADER,
452452
})
453453

454-
source = None
454+
# source = None
455+
source = ''
455456
if constants.CAT_README_URL in repository_metadata.results:
456457
source = repository_metadata.results[constants.CAT_README_URL][0]
457458
source = source[constants.PROP_RESULT][constants.PROP_VALUE]

src/somef/test/test_codemeta_parser.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import unittest
22
import os
33
import yaml
4+
import logging
45
from pathlib import Path
56

67
from somef.parser.codemeta_parser import parse_codemeta_json_file
78
from somef.process_results import Result
89
from somef.utils import constants
910

11+
logging.basicConfig(level=logging.INFO)
1012
TEST_ROOT = Path(__file__).parent
1113
REPOS_DIR = TEST_ROOT / "test_data" / "repositories"
1214
EXPECT_DIR = TEST_ROOT / "test_data" / "expected"
@@ -19,19 +21,23 @@ def load_expected(self, repo_name):
1921
if not yaml_path.exists():
2022
if repo_name == "codemeta_repo":
2123
return {}
22-
self.skipTest(f"No expected YAML for repository '{repo_name}'")
24+
# self.skipTest(f"No expected YAML for repository '{repo_name}'")
25+
logging.warning(f"No expected YAML for repository '{repo_name}'")
26+
return None
2327
with open(yaml_path, "r", encoding="utf-8") as f:
2428
return yaml.safe_load(f)
2529

2630
def test_parse_multiple_codemeta_files(self):
2731
for repo_folder in os.listdir(REPOS_DIR):
28-
print(f"################# Testing {repo_folder} #################")
32+
logging.info(f"################# Testing {repo_folder} #################")
2933
repo_path = REPOS_DIR / repo_folder
3034
codemeta_path = repo_path / "codemeta.json"
3135
if not codemeta_path.is_file():
3236
continue
3337

3438
expected = self.load_expected(repo_folder)
39+
if expected is None:
40+
continue
3541
result = Result()
3642
metadata_result = parse_codemeta_json_file(
3743
str(codemeta_path),
@@ -42,7 +48,7 @@ def test_parse_multiple_codemeta_files(self):
4248
with self.subTest(repo=repo_folder):
4349
# In order for us to check every test, we need every file in "expected" directory to be of .yaml,
4450
# and make sure the name is the same as the repo folder
45-
print(f"################# Processing expectation of {repo_folder} #################")
51+
logging.info(f"################# Processing expectation of {repo_folder} #################")
4652
for cat_name, expected_val in expected.items():
4753
cat_const = getattr(constants, cat_name)
4854
actual_list = metadata_result.results.get(cat_const, [])

src/somef/test/test_data/expected/runtime_platform_repo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ CAT_PROGRAMMING_LANGUAGES:
66
name: Java
77
value: Java
88
version: "1.8"
9-
type: Language
9+
type: Programming_language

0 commit comments

Comments
 (0)