diff --git a/scripts/test_update_index.py b/scripts/test_update_index.py index 25d65c35..282202ab 100644 --- a/scripts/test_update_index.py +++ b/scripts/test_update_index.py @@ -210,7 +210,7 @@ def test_find_insert_position_with_correct_previous_version_given_in_between_pos #TODO not working correclty - fix issue in code - #TODO fix test and behaviour + #TODO fix behaviour (not test) def test_run_update_html_twice_and_determine_insertion_position(self): """ Test case for the `update_index_html` function. @@ -252,7 +252,8 @@ def test_run_update_html_twice_and_determine_insertion_position(self): # Check order of both versions in the mock file content self.assertIn(version1, mock_file_content) self.assertIn(version2, mock_file_content) - self.assertLess(mock_file_content.index(version1), mock_file_content.index(version2)) + print(mock_file_content) + self.assertLess(mock_file_content.index(version2), mock_file_content.index(version1)) # version2 (3.0.7) should occur before version1 (3.0.6), since order is descending diff --git a/scripts/update_index.py b/scripts/update_index.py index ca1073b0..1dea19eb 100644 --- a/scripts/update_index.py +++ b/scripts/update_index.py @@ -65,8 +65,9 @@ def find_insert_position(content, version): def update_content(content, new_row, insert_position): return content[:insert_position] + new_row + content[insert_position:] -def update_index_html(version=None): - content = read_index_html() +def update_index_html(version=None, content=None): + if content is None: + content = read_index_html() is_valid, message = validate_version(version, content) if not is_valid: print(message) @@ -79,12 +80,14 @@ def update_index_html(version=None): print(message_position) return False updated_content = update_content(content, new_row, position_found) - write_index_html(updated_content) - print(f"Successfully updated index.html with version {version}") + return(updated_content) + if __name__ == "__main__": if len(sys.argv) > 1: version = sys.argv[1] else: version = None - update_index_html(version) \ No newline at end of file + updated_content = update_index_html(version) + write_index_html(updated_content) + print(f"Successfully updated index.html with version {version}") \ No newline at end of file