Skip to content
Browse files

Replace fixed data with YAML fixture

  • Loading branch information...
1 parent 369c43c commit 02f5cb814732872099bb8a7e7dc749f2215f5061 @olleolleolle olleolleolle committed
Showing with 26 additions and 15 deletions.
  1. +18 −0 fixture.yaml
  2. +8 −15 mugshots.py
View
18 fixture.yaml
@@ -0,0 +1,18 @@
+circles:
+ -
+ id: 1
+ name: Software
+ mnemonic: software
+ -
+ id: 2
+ name: Hardware
+ mnemonic: hardware
+
+people:
+ - olleolleolle
+ - jonasb
+ - qzio
+ - phrst
+ - lakevalley
+ - stg
+ - pipeunderscoreslash
View
23 mugshots.py
@@ -5,6 +5,7 @@
import sys
import os
import secret_key
+import yaml
app = Flask(__name__)
app.secret_key = secret_key.key
@@ -21,15 +22,16 @@ def get_date():
today = datetime.datetime.now().strftime('%Y-%m-%d')
return today
+def get_fixture_data():
+ with open("fixture.yaml", "r") as f:
+ return yaml.load(f.read())
+
@app.route("/setup-first")
def setup_first():
"""Set up a starting dataset.
"""
- circles = [
- dict(id=1, name="Software", mnemonic="software"),
- dict(id=2, name="Hardware", mnemonic="hardware")
- ]
- for c in circles:
+ fixture = get_fixture_data()
+ for c in fixture['circles']:
did_add = db.sadd('circles', c['mnemonic'])
if did_add:
circle_key = 'circle:%s' % c['mnemonic']
@@ -37,16 +39,7 @@ def setup_first():
db.hset(circle_key, 'name', c['name'])
db.hset(circle_key, 'mnemonic', c['mnemonic'])
- people = [
- 'olleolleolle',
- 'jonasb',
- 'qzio',
- 'phrst',
- 'lakevalley',
- 'stg',
- 'pipeunderscoreslash'
- ]
- for p in people:
+ for p in fixture['people']:
db.sadd('nicks', p)
db.save()

0 comments on commit 02f5cb8

Please sign in to comment.
Something went wrong with that request. Please try again.