Skip to content

Commit

Permalink
feat(#162): empty test case for final, defaults for non-maven
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Oct 21, 2024
1 parent fb75295 commit 5fc31ea
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions sr-data/src/sr_data/steps/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def main(repos, out, token):
frame.at[idx, "ppoms"] = profile["packages"]["poms"]
else:
frame.at[idx, "projects"] = 0
frame.at[idx, "plugins"] = "[]"
frame.at[idx, "pwars"] = 0
frame.at[idx, "pjars"] = 0
frame.at[idx, "ppoms"] = 0
before = len(frame)
frame = frame[frame.projects != 0]
logger.info(f"Skipped {before - len(frame)} repositories without pom.xml files")
Expand Down
14 changes: 14 additions & 0 deletions sr-data/src/tests/test_final.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,17 @@ def test_composes_into_final_csv(self):
final = pd.read_csv(path)
self.assertEqual(len(final.columns), 18)
self.assertEqual(len(final), 1)

@pytest.mark.fast
def test_composes_empty(self):
with TemporaryDirectory() as temp:
path = os.path.join(temp, "final.csv")
main(
os.path.join(
os.path.dirname(os.path.realpath(__file__)), "to-final-empty.csv"
),
path
)
final = pd.read_csv(path)
self.assertEqual(len(final.columns), 18)
self.assertEqual(len(final), 0)
21 changes: 20 additions & 1 deletion sr-data/src/tests/test_maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def test_skips_plugin_without_artifact(self):
"[org.jetbrains.kotlin:kotlin-maven-plugin,org.springframework.boot:spring-boot-maven-plugin]"
)


@pytest.mark.fast
def test_merges_projects_in_one_profile(self):
merged = merge(
Expand All @@ -108,3 +107,23 @@ def test_merges_projects_in_one_profile(self):
self.assertEqual(merged["packages"]["jars"], 2)
self.assertEqual(merged["packages"]["wars"], 0)
self.assertEqual(merged["packages"]["poms"], 0)

@pytest.mark.nightly
def test_returns_default_values_for_non_maven(self):
with TemporaryDirectory() as temp:
path = os.path.join(temp, "maven.csv")
main(
os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"to-maven-non-maven.csv"
),
path,
os.environ["GH_TESTING_TOKEN"]
)
frame = pd.read_csv(path)
self.assertEqual(len(frame.columns), 7)
self.assertTrue("projects" in frame.columns)
self.assertTrue("plugins" in frame.columns)
self.assertTrue("pwars" in frame.columns)
self.assertTrue("pjars" in frame.columns)
self.assertTrue("ppoms" in frame.columns)
1 change: 1 addition & 0 deletions sr-data/src/tests/to-final-empty.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repo,branch,readme,releases,issues,branches,pulls,headings,top,projects,plugins,pwars,pjars,ppoms,hnum,rlen,avg_slen,avg_wlen,mcw,example_wc,sample_wc,demonstration_wc
2 changes: 2 additions & 0 deletions sr-data/src/tests/to-maven-non-maven.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
repo,branch
h1alexbel/fakehub,master

0 comments on commit 5fc31ea

Please sign in to comment.