Skip to content

Commit ea47263

Browse files
committed
Merge pull request mjhea0#11 from mbreisch/master
Test Completed
2 parents 7373cf1 + ba2529b commit ea47263

File tree

16 files changed

+166
-11
lines changed

16 files changed

+166
-11
lines changed

.gitignore

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ venv
44
.DS_STORE
55
htmlcov
66
.coverage
7-
__pycache__
7+
__pycache__
8+
/.idea
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
def reverse(some_string: str) -> str:
3+
return some_string[::-1]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
from reverse_string import reverse
3+
4+
5+
class ReverseStringTests(unittest.TestCase):
6+
def test_reverse(self):
7+
my_string = "testing"
8+
my_reversed_string = "gnitset"
9+
10+
returned_string=reverse(my_string)
11+
assert my_reversed_string == returned_string
12+
13+
if __name__ == "__main__":
14+
unittest.main()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import unittest
2+
from vowel_counter import vowel_counter
3+
4+
5+
class VowelCounterTests(unittest.TestCase):
6+
def test_vowel_counter(self):
7+
my_string = 'abracadabra'
8+
vowel_count = vowel_counter(my_string)
9+
assert vowel_count == 5
10+
11+
if __name__ == '__main__':
12+
unittest.main()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
vowels=('a','e','i','o','u')
2+
3+
4+
def vowel_counter(some_string: str) -> int:
5+
count=0
6+
for letter in some_string:
7+
if letter in vowels:
8+
count += 1
9+
return count

part2/README.md

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
| [Gary Herd](https://github.com/garyherd/python-devtest) | [reverse-string](https://grh-reverse-string.herokuapp.com/) |
99
| [Noor Faziur Reza](https://github.com/ni8mr/python-devtest) | [reverse_string_reza](http://ni8mr2.herokuapp.com/) |
1010
| [AAkinkunmi](https://github.com/nubianMONK/python-devtest/tree/master/part2/reverse_flask_akinkunmi) | [reverse-flask](http://vast-forest-9436.herokuapp.com/) |
11+
| [Matthew Reisch](https://github.com/mbreisch/python-devtest) | [reverse-flask](https://vast-caverns-90155.herokuapp.com/) |
1112
| Add link here | Add link here |

part2/reverse_flask_reisch/Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: python run.py
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
import sys
3+
4+
pwd = os.path.abspath(os.path.dirname(__file__))
5+
project = os.path.basename(pwd)
6+
base_path = pwd.strip(project)
7+
new_path = os.path.join(base_path, 'project')
8+
9+
try:
10+
from project import app
11+
except ImportError:
12+
sys.path.append(full_path)
13+
from project import app
14+
15+
16+
def before_feature(context, feature):
17+
app.config['TESTING'] = True
18+
app.config['WTF_CSRF_ENABLED'] = False
19+
context.client = app.test_client()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Created by Matthew B. Reisch at 2/7/2016
2+
Feature: reverse_flask is operational in that users can submit a string via a form and view the word in reverse
3+
Scenario: successful string reversal
4+
Given reverse_flask is set up
5+
When we submit the form with the string "hello"
6+
Then we should see the output "olleh"
7+
8+
Scenario: unsuccessful string reversal
9+
Given reverse_flask is set up
10+
When we submit the form with the string " "
11+
Then we should see the alert "This field is required."
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from behave import *
2+
3+
4+
@given(u'reverse_flask is set up')
5+
def flask_is_setup(context):
6+
assert context.client
7+
8+
9+
@when(u'we submit the form with the string "{string_input}"')
10+
def submit_form(context, string_input):
11+
context.page = context.client.post('/', data=dict(input=string_input),follow_redirects=True)
12+
13+
14+
@then(u'we should see the output "{output}"')
15+
def output(context, output):
16+
assert output in context.page.data.decode()
17+
18+
19+
@then(u'we should see the alert "{message}"')
20+
def alert(context, message):
21+
assert message in context.page.data.decode()

0 commit comments

Comments
 (0)