Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 3 .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ venv
.DS_STORE
htmlcov
.coverage
__pycache__
__pycache__
/.idea
3 changes: 3 additions & 0 deletions 3 part1/reverse-string/reverse_reisch/reverse_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

def reverse(some_string: str) -> str:
return some_string[::-1]
14 changes: 14 additions & 0 deletions 14 part1/reverse-string/reverse_reisch/test_reverse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import unittest
from reverse_string import reverse


class ReverseStringTests(unittest.TestCase):
def test_reverse(self):
my_string = "testing"
my_reversed_string = "gnitset"

returned_string=reverse(my_string)
assert my_reversed_string == returned_string

if __name__ == "__main__":
unittest.main()
12 changes: 12 additions & 0 deletions 12 part1/vowel-counter/counter_reisch/test_vowel_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import unittest
from vowel_counter import vowel_counter


class VowelCounterTests(unittest.TestCase):
def test_vowel_counter(self):
my_string = 'abracadabra'
vowel_count = vowel_counter(my_string)
assert vowel_count == 5

if __name__ == '__main__':
unittest.main()
9 changes: 9 additions & 0 deletions 9 part1/vowel-counter/counter_reisch/vowel_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
vowels=('a','e','i','o','u')


def vowel_counter(some_string: str) -> int:
count=0
for letter in some_string:
if letter in vowels:
count += 1
return count
1 change: 1 addition & 0 deletions 1 part2/README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
| [Gary Herd](https://github.com/garyherd/python-devtest) | [reverse-string](https://grh-reverse-string.herokuapp.com/) |
| [Noor Faziur Reza](https://github.com/ni8mr/python-devtest) | [reverse_string_reza](http://ni8mr2.herokuapp.com/) |
| [AAkinkunmi](https://github.com/nubianMONK/python-devtest/tree/master/part2/reverse_flask_akinkunmi) | [reverse-flask](http://vast-forest-9436.herokuapp.com/) |
| [Matthew Reisch](https://github.com/mbreisch/python-devtest) | [reverse-flask](https://vast-caverns-90155.herokuapp.com/) |
| Add link here | Add link here |
1 change: 1 addition & 0 deletions 1 part2/reverse_flask_reisch/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: python run.py
19 changes: 19 additions & 0 deletions 19 part2/reverse_flask_reisch/features/environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import sys

pwd = os.path.abspath(os.path.dirname(__file__))
project = os.path.basename(pwd)
base_path = pwd.strip(project)
new_path = os.path.join(base_path, 'project')

try:
from project import app
except ImportError:
sys.path.append(full_path)
from project import app


def before_feature(context, feature):
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
context.client = app.test_client()
11 changes: 11 additions & 0 deletions 11 part2/reverse_flask_reisch/features/reverse.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Created by Matthew B. Reisch at 2/7/2016
Feature: reverse_flask is operational in that users can submit a string via a form and view the word in reverse
Scenario: successful string reversal
Given reverse_flask is set up
When we submit the form with the string "hello"
Then we should see the output "olleh"

Scenario: unsuccessful string reversal
Given reverse_flask is set up
When we submit the form with the string " "
Then we should see the alert "This field is required."
21 changes: 21 additions & 0 deletions 21 part2/reverse_flask_reisch/features/steps/reverse_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from behave import *


@given(u'reverse_flask is set up')
def flask_is_setup(context):
assert context.client


@when(u'we submit the form with the string "{string_input}"')
def submit_form(context, string_input):
context.page = context.client.post('/', data=dict(input=string_input),follow_redirects=True)


@then(u'we should see the output "{output}"')
def output(context, output):
assert output in context.page.data.decode()


@then(u'we should see the alert "{message}"')
def alert(context, message):
assert message in context.page.data.decode()
17 changes: 17 additions & 0 deletions 17 part2/reverse_flask_reisch/project/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from flask import Flask,render_template,request
from flask_bootstrap import Bootstrap
from .forms import ReverseForm

app=Flask(__name__)
app.config.from_pyfile('_config.py')
Bootstrap(app)

@app.route('/',methods=['POST','GET'])
def index():
error = None
form = ReverseForm(request.form)
if request.method == 'POST':
if form.validate_on_submit():
input_string=request.form['input']
return render_template('index.html',form=form,reversed_string=input_string[::-1])
return render_template('index.html',form=form,error=error)
3 changes: 3 additions & 0 deletions 3 part2/reverse_flask_reisch/project/_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
WTF_CSRF_ENABLED = True
SECRET_KEY = '\x07\xdd\xb7\x1e\xe8\x1d*\xe3`3\xa2\x9e\xf6\x94\xd4i\x14(\xa7\x93\xe5s\n\x8e'
DEBUG = True
7 changes: 7 additions & 0 deletions 7 part2/reverse_flask_reisch/project/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from flask_wtf import Form
from wtforms import StringField
from wtforms.validators import DataRequired


class ReverseForm(Form):
input = StringField('Input', validators=[DataRequired()])
26 changes: 26 additions & 0 deletions 26 part2/reverse_flask_reisch/project/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% extends "bootstrap/base.html" %}
{% block title %}Welcome to Reverse-A-Tron-5000 {% endblock %}
{% block content %}
<div class="reverse-input">
<h2>Please Enter a String to be Reversified</h2>
<form action="{{ url_for('index') }}" method="post">
{{ form.csrf_token }}
<p>
{{ form.input(placeholder="input a string here") }}
<span class="has-error">
{% if form.input.errors %}
{% for error in form.input.errors %}
{{ error }}
{% endfor %}
{% endif %}
</span>
</p>
<p>
<input class="btn btn-default" type="submit" value="Reversify">
</p>
</form>
<div class="reverse-output">
<p>Result: {{ reversed_string }}</p>
</div>
</div>
{% endblock %}
5 changes: 5 additions & 0 deletions 5 part2/reverse_flask_reisch/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os
from project import app

port=int(os.environ.get('PORT',5000))
app.run(host='0.0.0.0',port=port)
25 changes: 15 additions & 10 deletions 25 requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
Flask==0.10.1
Flask-WTF==0.11
Flask-Session==0.2
Flask-Bootstrap==3.3.4.1
gunicorn==19.3.0
Jinja2==2.7.3
MarkupSafe==0.23
WTForms==2.0.2
Werkzeug==0.10.4
itsdangerous==0.24
behave==1.2.5
Flask==0.10.1
Flask-Bootstrap==3.3.4.1
Flask-Session==0.2
Flask-WTF==0.11
gunicorn==19.3.0
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
parse==1.6.6
parse-type==0.3.4
six==1.10.0
Werkzeug==0.10.4
wheel==0.26.0
WTForms==2.0.2
Morty Proxy This is a proxified and sanitized view of the page, visit original site.