diff --git a/dataserv/Farmer.py b/dataserv/Farmer.py index 92d60a0..9414d15 100644 --- a/dataserv/Farmer.py +++ b/dataserv/Farmer.py @@ -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 diff --git a/tests/test_App.py b/tests/test_App.py index 8fea7c3..53044bb 100644 --- a/tests/test_App.py +++ b/tests/test_App.py @@ -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) + + diff --git a/tests/test_Farmer.py b/tests/test_Farmer.py index 939c3fe..6687db3 100644 --- a/tests/test_Farmer.py +++ b/tests/test_Farmer.py @@ -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) \ No newline at end of file