-
Notifications
You must be signed in to change notification settings - Fork 990
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added new module and test file for coinflip feature. (src/coinflip.py and tests/test_coinflip.py) * Fixed the typo error in test_coinflip.py * actually fixed the parenthesis error this time. * Changed module name to 'coinflip'. Cleaned up code. Fixed error in test.
- Loading branch information
1 parent
5128bf1
commit e3f9f58
Showing
3 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
'anime', | ||
'book', | ||
'bye', | ||
'coin', | ||
'currency', | ||
'dictionary', | ||
'fact', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import random | ||
from templates.text import TextTemplate | ||
|
||
def process(input, entities): | ||
output = {} | ||
output['input'] = input | ||
if random.randrange(0,2,1): | ||
output['output'] = TextTemplate("Sure, it's heads!").get_message() | ||
else: | ||
output['output'] = TextTemplate("Sure, it's tails!").get_message() | ||
output['success'] = True | ||
return output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import modules | ||
|
||
def test_coinflip(): | ||
assert('coin' == modules.process_query('Flip a coin')[0]) | ||
assert('coin' == modules.process_query('Jarvis flip a coin')[0]) | ||
assert('coin' == modules.process_query('Can you flip a coin')[0]) | ||
assert('coin' != modules.process_query('something random')[0]) |