aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-03-21 18:53:43 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-03-21 18:53:43 -0700
commit33492754881a27c88f6a1ed38e463bba15ecf837 (patch)
treee290f0719bc14c2d9590112652f8864ab9246229
parentd66fed95534d7a443e2cf84e9290d0c9bdf72311 (diff)
downloadfatcat-33492754881a27c88f6a1ed38e463bba15ecf837.tar.gz
fatcat-33492754881a27c88f6a1ed38e463bba15ecf837.zip
merge front and back
-rwxr-xr-xfatcat/backend.py (renamed from backend/backend.py)0
-rw-r--r--fatcat/static/robots.txt (renamed from webface/static/robots.txt)0
-rw-r--r--fatcat/templates/base.html (renamed from webface/templates/base.html)0
-rw-r--r--fatcat/templates/home.html (renamed from webface/templates/home.html)0
-rw-r--r--fatcat/templates/work_add.html (renamed from webface/templates/work_add.html)0
-rw-r--r--fatcat/templates/work_view.html (renamed from webface/templates/work_view.html)0
-rw-r--r--fatcat/test_backend.py53
-rwxr-xr-xfatcat/webface.py (renamed from webface/webface.py)0
8 files changed, 53 insertions, 0 deletions
diff --git a/backend/backend.py b/fatcat/backend.py
index a39ae790..a39ae790 100755
--- a/backend/backend.py
+++ b/fatcat/backend.py
diff --git a/webface/static/robots.txt b/fatcat/static/robots.txt
index a168f11b..a168f11b 100644
--- a/webface/static/robots.txt
+++ b/fatcat/static/robots.txt
diff --git a/webface/templates/base.html b/fatcat/templates/base.html
index 4e9dcd4b..4e9dcd4b 100644
--- a/webface/templates/base.html
+++ b/fatcat/templates/base.html
diff --git a/webface/templates/home.html b/fatcat/templates/home.html
index d9cc34a2..d9cc34a2 100644
--- a/webface/templates/home.html
+++ b/fatcat/templates/home.html
diff --git a/webface/templates/work_add.html b/fatcat/templates/work_add.html
index ac8a8169..ac8a8169 100644
--- a/webface/templates/work_add.html
+++ b/fatcat/templates/work_add.html
diff --git a/webface/templates/work_view.html b/fatcat/templates/work_view.html
index 8c5e955d..8c5e955d 100644
--- a/webface/templates/work_view.html
+++ b/fatcat/templates/work_view.html
diff --git a/fatcat/test_backend.py b/fatcat/test_backend.py
new file mode 100644
index 00000000..429b5ae7
--- /dev/null
+++ b/fatcat/test_backend.py
@@ -0,0 +1,53 @@
+
+import os
+import json
+import backend
+import unittest
+import tempfile
+from nose.tools import *
+
+# TODO: replace all these "assert" with unit test version (which displays left
+# and right on failure)
+
+# TODO: http://alextechrants.blogspot.com/2013/08/unit-testing-sqlalchemy-apps.html
+
+## Helpers ##################################################################
+
+def check_entity_fields(e):
+ for key in ('id', 'rev', 'previous', 'state', 'redirect_id', 'edit_id',
+ 'extra_json'):
+ assert_in(key, e)
+ for key in ('id', 'rev'):
+ assert_is_not_none(e[key])
+
+## API Tests ################################################################
+
+class BackendTestCase(unittest.TestCase):
+
+ def setUp(self):
+ backend.app.config['DATABASE_URI'] = 'sqlite://:memory:'
+ backend.app.testing = True
+ self.app = backend.app.test_client()
+
+ def test_health(self):
+ rv = self.app.get('/health')
+ obj = json.loads(rv.data.decode('utf-8'))
+ assert obj['ok']
+
+ def test_works(self):
+
+ # Invalid Id
+ rv = self.app.get('/v0/work/_')
+ assert rv.status_code == 404
+
+ # Missing Id (TODO)
+ #rv = self.app.get('/v0/work/rzga5b9cd7efgh04iljk')
+ #assert rv.status is 404
+
+ # Valid Id
+ rv = self.app.get('/v0/work/r3zga5b9cd7ef8gh084714iljk')
+ assert rv.status_code == 200
+ obj = json.loads(rv.data.decode('utf-8'))
+ check_entity_fields(obj)
+ assert obj['title']
+ assert_equal(obj['work_type'], "journal-article")
diff --git a/webface/webface.py b/fatcat/webface.py
index 33833e25..33833e25 100755
--- a/webface/webface.py
+++ b/fatcat/webface.py