Skip to content

Commit

Permalink
added get address api call
Browse files Browse the repository at this point in the history
  • Loading branch information
F483 committed Aug 20, 2015
1 parent 2b5a09a commit 7f1c744
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ help:
@echo "Some usefull development shortcuts."
@echo " clean Remove all generated files."
@echo " setup Setup development environment."
@echo " shell Open ipython from the development environment."
@echo " test Run tests and analysis tools."
@echo " wheel Build package wheel and save in '$(WHEEL_DIR)'."
@echo " wheels Build dependencie wheels and save in '$(WHEEL_DIR)'."
Expand Down Expand Up @@ -50,6 +51,10 @@ setup: virtualenv
$(PIP) install $(USE_WHEEL) -r develop_requirements.txt


shell: setup
env/bin/ipython


test: setup
$(PY) setup.py test

Expand Down
5 changes: 5 additions & 0 deletions dataserv/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ def ping(btc_addr):
return make_response(error_msg.format(msg), 404)


@app.route('/api/address', methods=["GET"])
def get_address():
return jsonify({ "address": app.config["ADDRESS"] })


@app.route('/api/online', methods=["GET"])
def online():
# this could be formatted a bit better, but we just want to publicly display
Expand Down
7 changes: 7 additions & 0 deletions tests/test_App.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import json
from btctxstore import BtcTxStore
from dataserv.run import app, db
from dataserv.app import secs_to_mins, online_farmers
Expand Down Expand Up @@ -192,6 +193,12 @@ def test_farmer_order(self):
farmers = online_farmers()
self.assertEqual(farmers[0].btc_addr, addr1)

def test_get_address(self):
rv = self.app.get('/api/address')
self.assertEqual(rv.status_code, 200)
data = rv.data.decode("utf-8")
self.assertEqual(app.config["ADDRESS"], json.loads(data)["address"])


class AppAuthenticationHeadersTest(unittest.TestCase):

Expand Down

0 comments on commit 7f1c744

Please sign in to comment.