Skip to content

Commit

Permalink
Fixed Height Bug and Added Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
super3 committed Aug 7, 2015
1 parent d8c299f commit 37ea4a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dataserv/Farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def set_height(self, height):
"""Set the farmers advertised height."""
self.validate()

self.height = height
farmer = self.lookup()
farmer.height = height
db.session.commit()

return self.height
6 changes: 5 additions & 1 deletion tests/test_App.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,14 @@ def test_farmer_set_height(self):
self.app.get('/api/register/{0}'.format(addr1))

# correct
rv = self.app.get('/api/height/{0}/1'.format(addr1))
rv = self.app.get('/api/height/{0}/5'.format(addr1))
self.assertEqual(rv.status_code, 200)
rv = self.app.get('/api/online'.format(addr1))
self.assertTrue(b"Height: 5" in rv.data)

# invalid btc address
rv = self.app.get('/api/height/{0}/1'.format(addr2))
self.assertEqual(rv.status_code, 400)



4 changes: 4 additions & 0 deletions tests/test_Farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ def test_height(self):

self.assertEqual(farmer.height, 0)
self.assertEqual(farmer.set_height(5), 5)
self.assertEqual(farmer.height, 5)

farmer2 = farmer.lookup()
self.assertEqual(farmer2.height, 5)

0 comments on commit 37ea4a8

Please sign in to comment.