Skip to content

Commit 59c22cf

Browse files
sandra0521AntiDog
authored andcommitted
STCC-134 Replace conversion error with warning and adapt testcases (#118)
1 parent 4c8587b commit 59c22cf

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

config/default.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Scratch2Catrobat Converter
44
short_name: S2CC
55
version: 0.10.0
66
build_name: Aegean cat
7-
build_number: 980
7+
build_number: 984
88

99
;-------------------------------------------------------------------------------
1010
[CATROBAT]

src/scratchtocatrobat/converter/converter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ def _convert_sound_block(self):
19911991
[sound_name], sound_list = self.arguments, self.sprite.getSoundList()
19921992
sound_data = {sound_info.getName(): sound_info for sound_info in sound_list}.get(sound_name)
19931993
if not sound_data:
1994-
raise ConversionError("Sprite does not contain sound with name={}".format(sound_name))
1994+
log.warning("Sprite does not contain sound with name={}".format(sound_name))
19951995
play_sound_brick = self.CatrobatClass()
19961996
play_sound_brick.setSound(sound_data)
19971997
return play_sound_brick
@@ -2001,7 +2001,7 @@ def _convert_sound_and_wait_block(self):
20012001
[sound_name], sound_list = self.arguments, self.sprite.getSoundList()
20022002
sound_data = {sound_info.getName(): sound_info for sound_info in sound_list}.get(sound_name)
20032003
if not sound_data:
2004-
raise ConversionError("Sprite does not contain sound with name={}".format(sound_name))
2004+
log.warning("Sprite does not contain sound with name={}".format(sound_name))
20052005
play_sound_and_wait_brick = self.CatrobatClass()
20062006
play_sound_and_wait_brick.setSound(sound_data)
20072007
return play_sound_and_wait_brick

src/scratchtocatrobat/converter/test_converter.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1011,11 +1011,12 @@ def test_can_convert_waitelapsedfrom_block(self):
10111011
assert formula_tree_seconds.value == "1"
10121012

10131013
# playSound:
1014-
def test_fail_convert_playsound_block_if_sound_missing(self):
1014+
def test_can_convert_playsound_block_if_sound_missing(self):
10151015
scratch_block = ["playSound:", "bird"]
10161016
bricks = self.block_converter._catrobat_bricks_from(scratch_block, DUMMY_CATR_SPRITE)
10171017
assert len(bricks) == 1
1018-
assert isinstance(bricks[0], catbricks.NoteBrick)
1018+
assert isinstance(bricks[0], catbricks.PlaySoundBrick)
1019+
assert bricks[0].sound is None
10191020

10201021
# playSound:
10211022
def test_can_convert_playsound_block(self):
@@ -1026,11 +1027,12 @@ def test_can_convert_playsound_block(self):
10261027
assert catr_brick.sound.getName() == expected_sound_name
10271028

10281029
# doPlaySoundAndWait
1029-
def test_fail_convert_doplaysoundandwait_block(self):
1030+
def test_can_convert_playsoundandwait_block_if_sound_missing(self):
10301031
scratch_block = ["doPlaySoundAndWait", "bird"]
10311032
bricks = self.block_converter._catrobat_bricks_from(scratch_block, DUMMY_CATR_SPRITE)
10321033
assert len(bricks) == 1
1033-
assert isinstance(bricks[0], catbricks.NoteBrick)
1034+
assert isinstance(bricks[0], catbricks.PlaySoundAndWaitBrick)
1035+
assert bricks[0].sound is None
10341036

10351037
# doPlaySoundAndWait
10361038
def test_can_convert_doplaysoundandwait_block(self):

0 commit comments

Comments
 (0)