Skip to content

Commit

Permalink
pointing at generated templates in test
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Oct 20, 2012
1 parent bb7c01e commit d599a45
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install:
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
script: blockd3_tests/run.py -v
script: blockd3_tests/run.py
# blacklist
branches:
except:
Expand Down
54 changes: 48 additions & 6 deletions blockd3_tests/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from os.path import join as opj
from os.path import abspath as opa

import sh

from flask import (
Flask,
)
Expand Down Expand Up @@ -32,6 +34,12 @@ def make_app(env="dev"):
template_folder="..",
static_folder=opa(opj(app_home, "..", "dist"))
)
"test": dict(
static_url_path="/dist",
template_folder="../dist",
static_folder=opa(opj(app_home, "..", "dist"))
)
)
}[env]

app = Flask(__name__, **cfg)
Expand All @@ -41,15 +49,20 @@ def make_app(env="dev"):

@app.route(url_root)
def home():
return render_template("index.html",
env=env,
**assets())

kwargs = {}
if env != "test":
kwargs(assets())

return render_template("index.html", env=env, **kwargs)

@app.route(url_root + "frame/")
def frame():
return render_template("frame/index.html",
env=env,
**assets("../frame"))
kwargs = {}
if env != "test":
kwargs(assets())

return render_template("frame/index.html", env=env, **kwargs)

return app

Expand All @@ -67,7 +80,36 @@ def assets(for_file="../"):
in open(a_list).read().split("\n")
if asset.strip() and not asset.strip().startswith("#")
]

if for_file == "../":
result.update(runtime_assets())

return result

def runtime_assets():
rt_cfg = dict(
themes=dict(
path="lib/swatch/*.css",
thing="theme",
sub_data=lambda x: x.split(".")[1],
sub_text=lambda x: x
),
example=dict(
path="blockml/*.xml",
thing="example",
sub_data=lambda x: os.path.basename(x)[0:-4],
sub_text=lambda x: " ".join(x.split("_")).title()
)
)

result = {}

for thing, cfg in rt_cfg.items():
result[thing] = sorted([
(cfg["sub_text"](cfg["sub_data"](path)), cfg["sub_data"](path))
for path in sh.glob(cfg["path"])
], key=lambda x: x[0].upper())
return result

if __name__ == "__main__":
app = make_app()
Expand Down
2 changes: 1 addition & 1 deletion blockd3_tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ghost import GhostTestCase, Ghost
from app import make_app

app = make_app()
app = make_app("test")

PORT = 5000

Expand Down

0 comments on commit d599a45

Please sign in to comment.