Skip to content

Commit

Permalink
fix test behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
f-peverali committed Oct 15, 2024
1 parent dff82f4 commit bf33e47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions scripts/test_update_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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



Expand Down
13 changes: 8 additions & 5 deletions scripts/update_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
updated_content = update_index_html(version)
write_index_html(updated_content)
print(f"Successfully updated index.html with version {version}")

0 comments on commit bf33e47

Please sign in to comment.