Skip to content

Commit

Permalink
implement test_add_id_to_local_song_if_available_in_ct #13
Browse files Browse the repository at this point in the history
  • Loading branch information
bensteUEM committed May 7, 2024
1 parent 1e9f668 commit e3e59c4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ def add_id_to_local_song_if_available_in_ct(
logging.info("Starting add_id_to_local_song_if_available_in_ct()")
logging.critical(
"This function might destroy your data in case a songname exists twice in one songbook #13"
) # 13 TODO
)
# TODO (bensteUEM): Extend functionality of add_id_to_local_song_if_available_in_ct()
# https://github.com/bensteUEM/SongBeamerQS/issues/13

compare_by_id_df = validate_ct_songs_exist_locally_by_id(df_ct, df_sng)

Expand Down
13 changes: 9 additions & 4 deletions testData/Test/sample_no_ct.sng
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#LangCount=1
#Editor=Benedict's Python Script am 2023-01-22
#LangCount=1
#Editor=Benedict's Python Script am 2024-05-06
#Version=3
#Title=Test
#Author=TestAuthor
#Title=sample_no_ct
#Author=Benedict
#BackgroundImage=_ChurchMediaDrop\Dan-Stevers_Ascent_Stills\smeary clouds_4k.jpg
#VerseOrder=Intro,Vers 1,STOP
#Songbook=
Expand All @@ -12,3 +12,8 @@ Intro
---
Vers 1
This file can be used for any testing that has valid data but no ChurchTools id yet
used in test_main.py
* test_add_id_to_local_song_if_available_in_ct
* test_upload_new_local_songs_and_generate_ct_id
* test_upload_local_songs_by_id
* test_apply_ct_song_sng_count_qs_tag
25 changes: 19 additions & 6 deletions test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import SNG_DEFAULTS
from main import (
add_id_to_local_song_if_available_in_ct,
apply_ct_song_sng_count_qs_tag,
check_ct_song_categories_exist_as_folder,
download_missing_online_songs,
Expand Down Expand Up @@ -200,12 +201,24 @@ def test_emptied_song(self) -> None:

def test_add_id_to_local_song_if_available_in_ct(self) -> None:
"""This should verify that add_id_to_local_song_if_available_in_ct is working as expected."""
self.assertFalse(
True,
"Not Implemented see https://github.com/bensteUEM/SongBeamerQS/issues/13",
)
# TODO (bensteUEM): implement test_add_id_to_local_song_if_available_in_ct
# https://github.com/bensteUEM/SongBeamerQS/issues/13
test_dir = Path("./testData/Test")
test_filename = "sample_no_ct.sng"
copyfile(test_dir / test_filename, test_dir / (test_filename + "_bak"))
song = SngFile(test_dir / test_filename)
self.assertNotIn("id", song.header)

test_local_df = pd.DataFrame([song], columns=["SngFile"])
test_local_df["filename"] = test_filename
test_local_df["path"] = test_dir

test_ct_id = 3064
test_ct_df = pd.json_normalize(self.api.get_songs(song_id=test_ct_id))

add_id_to_local_song_if_available_in_ct(df_sng=test_local_df, df_ct=test_ct_df)
self.assertEqual(song.header["id"], str(test_ct_id))

# cleanup
(test_dir / (test_filename + "_bak")).rename(test_dir / test_filename)

def test_download_missing_online_songs(self) -> None:
"""ELKW1610.krz.tools specific test case for the named function (using 2 specific song IDs).
Expand Down

0 comments on commit e3e59c4

Please sign in to comment.