Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs1-24fa
project03
Commits
5856dcdf
Commit
5856dcdf
authored
6 months ago
by
Antonio Caceres
Browse files
Options
Download
Email Patches
Plain Diff
Rename translate_complete_morse_symbol to append_morse_symbol and fix LHS/RHS output accordingly.
parent
d6c5ad09
master
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/morse_code.py
+1
-1
src/morse_code.py
tests/0.D/test_append_morse_symbol.py
+9
-8
tests/0.D/test_append_morse_symbol.py
with
10 additions
and
9 deletions
+10
-9
src/morse_code.py
View file @
5856dcdf
from
.symbols
import
MORSE_SYMBOL_TO_LETTER
,
InvalidSymbolError
def
translate_complete
_morse_symbol
(
message
,
symbol
):
def
append
_morse_symbol
(
message
,
symbol
):
"""
Decodes a Morse code symbol and appends the corresponding character to the
message.
...
...
This diff is collapsed.
Click to expand it.
tests/0.D/test_
translate_complete
_morse_symbol.py
→
tests/0.D/test_
append
_morse_symbol.py
View file @
5856dcdf
import
pytest
from
src.morse_code
import
translate_complete
_morse_symbol
from
src.morse_code
import
append
_morse_symbol
from
src.symbols
import
InvalidSymbolError
from
tests.helpers.translate_symbol_data
import
SINGLE_SYMBOL_TESTS
from
tests.helpers.naming
import
apply_names
...
...
@@ -9,24 +9,24 @@ from tests.helpers.naming import apply_names
@
pytest
.
mark
.
parametrize
(
"seq, msg, expected"
,
apply_names
(
"
translate_complete
_morse_symbol"
,
[
True
,
True
,
False
],
SINGLE_SYMBOL_TESTS
"
append
_morse_symbol"
,
[
True
,
True
,
False
],
SINGLE_SYMBOL_TESTS
),
)
def
test_add_random
(
seq
,
msg
,
expected
):
if
expected
is
None
:
with
pytest
.
raises
(
InvalidSymbolError
):
result
=
translate_complete
_morse_symbol
(
msg
,
seq
)
append
_morse_symbol
(
msg
,
seq
)
else
:
result
=
translate_complete
_morse_symbol
(
msg
,
seq
)
result
=
append
_morse_symbol
(
msg
,
seq
)
assert
(
result
==
expected
expected
==
result
),
"a valid morse code symbol wasn't translated correctly"
@
pytest
.
mark
.
parametrize
(
"msg, expected"
,
apply_names
(
"
translate_complete
_morse_symbol"
,
"
append
_morse_symbol"
,
[
True
,
False
],
[
(
"JUMPOUTTHEHOUSE"
,
"JUMPOUTTHEHOUS"
),
...
...
@@ -40,5 +40,6 @@ def test_add_random(seq, msg, expected):
),
)
def
test_delete
(
msg
,
expected
):
result
=
translate_complete_morse_symbol
(
msg
,
"......"
)
assert
result
==
expected
result
=
append_morse_symbol
(
msg
,
"......"
)
assert
expected
==
result
,
(
"the delete symbol was not translated correctly; "
"check src/symbols.py for the morse code mapping"
)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help