Skip to content

Commit

Permalink
Paired Challenge Exercise: design single function program
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdans13 committed Feb 5, 2024
0 parents commit 1b26bca
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pytest = "*"

[dev-packages]

[requires]
python_version = "3.11"
54 changes: 54 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added lib/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions lib/todo_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# As a user
# So that I can keep track of my tasks
# I want to check if a text includes the string `#TODO`.

def check_todo(text):
if '#TODO' in text.upper():
return text
else:
raise Exception('No #TODO tasks')
Empty file added tests/__init__.py
Empty file.
63 changes: 63 additions & 0 deletions tests/test_todo_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# As a user
# So that I can keep track of my tasks
# I want to check if a text includes the string `#TODO`.

'''
check
def check_todo(text):
param = (text)
text: string containing multiple things including ideally '#TODO'
return:
string if it contains '#TODO'
side effects:
if there isn't any '#TODO' it would return error saying there's no tasks
'''
pass


from lib.todo_list import check_todo
import pytest


'''
test to see if the text has no content
'''

def test_check_no_content():

with pytest.raises(Exception) as err:
outcome = check_todo('')
error = str(err.value)
assert error == 'No #TODO tasks'


'''
check if the text contains '#TODO'
'''

def test_check_todo():
tasks = check_todo('testing to see if #TODO is detected')
assert tasks == 'testing to see if #TODO is detected'

'''
check for the absence of #TODO
'''

def test_check_lack_of_todo():

with pytest.raises(Exception) as err:
no_tasks = check_todo('testing to see if this works')
error_msg = str(err.value)
assert error_msg == 'No #TODO tasks'


'''
check for #TODO but not necesarily in capitals
'''

def test_todos_in_lowerc():
todos = check_todo('testing to see if #toDo works')
assert todos == 'testing to see if #toDo works'

0 comments on commit 1b26bca

Please sign in to comment.