Skip to content

Commit

Permalink
(minor) update comment for assertReadmeContents and mkae the car name…
Browse files Browse the repository at this point in the history
… expected_file_path instead of expected_contents_file, output_content to result_content for clarity, remove extra whitespace
  • Loading branch information
nozomione committed Sep 25, 2024
1 parent bd8384b commit fd83801
Showing 1 changed file with 21 additions and 30 deletions.
51 changes: 21 additions & 30 deletions api/scpca_portal/test/test_readme_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@


class TestReadmeFileContents(TestCase):
def assertReadmeContents(self, expected_file_path: str, output_content: str) -> None:
def assertReadmeContents(self, expected_file_path: str, result_content: str) -> None:
def get_updated_content(content: str) -> str:
"""
Replace the placeholder TEST_TODAYS_DATE in test/expected_values/readmes
with the given project_id and today's date respectively for format testing.
with today's date for format testing.
"""
content = content.replace(
"Generated on: TEST_TODAYS_DATE", f"Generated on: {utils.get_today_string()}"
)

return content.strip()

with open(expected_file_path, "r", encoding="utf-8") as expected_file:
with open(expected_file_path, encoding="utf-8") as expected_file:
expected_content = get_updated_content(expected_file.read())

# Convert expected and output contents to line lists for easier debugging
# Convert expected and result contents to line lists for easier debugging
self.assertEqual(
expected_content.splitlines(True),
output_content.splitlines(True),
result_content.splitlines(True),
f"{self._testMethodName}: Comparison with {expected_file_path} does not match.",
)

Expand All @@ -40,10 +39,9 @@ def test_readme_file_PORTAL_ALL_METADATA(self):
)
for project_id in PROJECT_IDS
]

result = readme_file.get_file_contents(DOWNLOAD_CONFIG, projects)
expect_contents_file = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expect_contents_file, result)
expected_file_path = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expected_file_path, result)

def test_readme_file_ALL_METADATA(self):
DOWNLOAD_CONFIG_NAME = "ALL_METADATA"
Expand All @@ -53,10 +51,9 @@ def test_readme_file_ALL_METADATA(self):
project = ProjectFactory(
additional_restrictions="Research or academic purposes only", scpca_id=PROJECT_ID
)

result = readme_file.get_file_contents(DOWNLOAD_CONFIG, [project])
expect_contents_file = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expect_contents_file, result)
expected_file_path = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expected_file_path, result)

def test_readme_file_SINGLE_CELL_SINGLE_CELL_EXPERIMENT(self):
DOWNLOAD_CONFIG_NAME = "SINGLE_CELL_SINGLE_CELL_EXPERIMENT"
Expand All @@ -66,10 +63,9 @@ def test_readme_file_SINGLE_CELL_SINGLE_CELL_EXPERIMENT(self):
project = ProjectFactory(
additional_restrictions="Research or academic purposes only", scpca_id=PROJECT_ID
)

result = readme_file.get_file_contents(DOWNLOAD_CONFIG, [project])
expect_contents_file = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expect_contents_file, result)
expected_file_path = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expected_file_path, result)

def test_readme_file_SINGLE_CELL_SINGLE_CELL_EXPERIMENT_MULTIPLEXED(self):
DOWNLOAD_CONFIG_NAME = "SINGLE_CELL_SINGLE_CELL_EXPERIMENT_MULTIPLEXED"
Expand All @@ -79,10 +75,9 @@ def test_readme_file_SINGLE_CELL_SINGLE_CELL_EXPERIMENT_MULTIPLEXED(self):
project = ProjectFactory(
additional_restrictions="Research or academic purposes only", scpca_id=PROJECT_ID
)

result = readme_file.get_file_contents(DOWNLOAD_CONFIG, [project])
expect_contents_file = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expect_contents_file, result)
expected_file_path = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expected_file_path, result)

def test_readme_file_SINGLE_CELL_SINGLE_CELL_EXPERIMENT_MERGED(self):
DOWNLOAD_CONFIG_NAME = "SINGLE_CELL_SINGLE_CELL_EXPERIMENT_MERGED"
Expand All @@ -92,10 +87,9 @@ def test_readme_file_SINGLE_CELL_SINGLE_CELL_EXPERIMENT_MERGED(self):
project = ProjectFactory(
additional_restrictions="Research or academic purposes only", scpca_id=PROJECT_ID
)

result = readme_file.get_file_contents(DOWNLOAD_CONFIG, [project])
expect_contents_file = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expect_contents_file, result)
expected_file_path = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expected_file_path, result)

def test_readme_file_SINGLE_CELL_ANN_DATA(self):
DOWNLOAD_CONFIG_NAME = "SINGLE_CELL_ANN_DATA"
Expand All @@ -105,10 +99,9 @@ def test_readme_file_SINGLE_CELL_ANN_DATA(self):
project = ProjectFactory(
additional_restrictions="Research or academic purposes only", scpca_id=PROJECT_ID
)

result = readme_file.get_file_contents(DOWNLOAD_CONFIG, [project])
expect_contents_file = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expect_contents_file, result)
expected_file_path = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expected_file_path, result)

def test_readme_file_SINGLE_CELL_ANN_DATA_MERGED(self):
DOWNLOAD_CONFIG_NAME = "SINGLE_CELL_ANN_DATA_MERGED"
Expand All @@ -118,10 +111,9 @@ def test_readme_file_SINGLE_CELL_ANN_DATA_MERGED(self):
project = ProjectFactory(
additional_restrictions="Research or academic purposes only", scpca_id=PROJECT_ID
)

result = readme_file.get_file_contents(DOWNLOAD_CONFIG, [project])
expect_contents_file = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expect_contents_file, result)
expected_file_path = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expected_file_path, result)

def test_readme_file_SPATIAL_SINGLE_CELL_EXPERIMENT(self):
DOWNLOAD_CONFIG_NAME = "SPATIAL_SINGLE_CELL_EXPERIMENT"
Expand All @@ -131,7 +123,6 @@ def test_readme_file_SPATIAL_SINGLE_CELL_EXPERIMENT(self):
project = ProjectFactory(
additional_restrictions="Research or academic purposes only", scpca_id=PROJECT_ID
)

result = readme_file.get_file_contents(DOWNLOAD_CONFIG, [project])
expect_contents_file = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expect_contents_file, result)
expected_file_path = README_DIR / f"{DOWNLOAD_CONFIG_NAME}.md"
self.assertReadmeContents(expected_file_path, result)

0 comments on commit fd83801

Please sign in to comment.