diff --git a/main.py b/main.py index ec7c8e7..7506b6b 100644 --- a/main.py +++ b/main.py @@ -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) diff --git a/testData/Test/sample_no_ct.sng b/testData/Test/sample_no_ct.sng index 42fff11..ad11af3 100644 --- a/testData/Test/sample_no_ct.sng +++ b/testData/Test/sample_no_ct.sng @@ -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= @@ -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 diff --git a/test_main.py b/test_main.py index ecaaffb..56a505d 100644 --- a/test_main.py +++ b/test_main.py @@ -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, @@ -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).