Browse Source

Add a tasks.py for invoke usage

Getty Ritter 4 years ago
parent
commit
8cfc17f512
5 changed files with 35 additions and 2 deletions
  1. 7 0
      lc/main.py
  2. 1 1
      lc/routes.py
  3. 14 1
      poetry.lock
  4. 1 0
      pyproject.toml
  5. 12 0
      tasks.py

+ 7 - 0
lc/main.py

@@ -0,0 +1,7 @@
+import os
+
+import lc.config
+import lc.routes
+
+lc.config.DB.init(os.getenv('DB_LOC', 'test.db'))
+app = lc.routes.app

+ 1 - 1
lc/routes.py

@@ -6,7 +6,7 @@ import lc.model as m
 
 LOADER = pystache.loader.Loader(
     extension='mustache',
-    search_dirs=[os.path.join(PROJ_ROOT, 'templates')],
+    search_dirs=['templates'],
 )
 
 app = flask.Flask(__name__)

+ 14 - 1
poetry.lock

@@ -98,6 +98,14 @@ optional = false
 python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
 version = "2.9"
 
+[[package]]
+category = "dev"
+description = "Pythonic task execution"
+name = "invoke"
+optional = false
+python-versions = "*"
+version = "1.4.1"
+
 [[package]]
 category = "main"
 description = "Various helpers to pass data to untrusted environments and back."
@@ -334,7 +342,7 @@ dev = ["pytest", "pytest-timeout", "coverage", "tox", "sphinx", "pallets-sphinx-
 watchdog = ["watchdog"]
 
 [metadata]
-content-hash = "6c511d6a79eaa8c96c073cf0cdfb5298d981d7aa6fcbaeb0e8287b7ebbf4a468"
+content-hash = "c29c29e9b0856a06a99e4913f20250c10d0f08f00428a5a674a3c04de5859105"
 python-versions = "^3.8"
 
 [metadata.files]
@@ -374,6 +382,11 @@ idna = [
     {file = "idna-2.9-py2.py3-none-any.whl", hash = "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"},
     {file = "idna-2.9.tar.gz", hash = "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb"},
 ]
+invoke = [
+    {file = "invoke-1.4.1-py2-none-any.whl", hash = "sha256:93e12876d88130c8e0d7fd6618dd5387d6b36da55ad541481dfa5e001656f134"},
+    {file = "invoke-1.4.1-py3-none-any.whl", hash = "sha256:87b3ef9d72a1667e104f89b159eaf8a514dbf2f3576885b2bbdefe74c3fb2132"},
+    {file = "invoke-1.4.1.tar.gz", hash = "sha256:de3f23bfe669e3db1085789fd859eb8ca8e0c5d9c20811e2407fa042e8a5e15d"},
+]
 itsdangerous = [
     {file = "itsdangerous-1.1.0-py2.py3-none-any.whl", hash = "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"},
     {file = "itsdangerous-1.1.0.tar.gz", hash = "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19"},

+ 1 - 0
pyproject.toml

@@ -14,6 +14,7 @@ dataclasses-json = "^0.4.2"
 
 [tool.poetry.dev-dependencies]
 pytest = "^5.4.1"
+invoke = "^1.4.1"
 
 [build-system]
 requires = ["poetry>=0.12"]

+ 12 - 0
tasks.py

@@ -0,0 +1,12 @@
+from invoke import task
+
+@task
+def test(c):
+    c.run('poetry run python -m pytest tests/*.py')
+
+@task
+def run(c, port=8080, host='127.0.0.1'):
+    c.run(
+        f'poetry run python -m flask run -p {port} -h {host}',
+        env={'FLASK_APP': 'lc/main.py'},
+    )