def test_add_homegroup(self): """Make sure we can add a new homegroup""" row_count = db.create_homegroup('Test HomeGroup', 'Test Location', 'Test Description', None, None) self.assertEqual(row_count, 1) homegroup_id = db.recent_homegroup()['id'] test_hg = db.find_homegroup(homegroup_id) self.assertIsNotNone(test_hg) self.assertEqual(test_hg['Name'], 'Test HomeGroup') self.assertEqual(test_hg['Location'], 'Test Location') self.assertEqual(test_hg['Description'], 'Test Description')
def test_edit_homegroup(self): """Make sure we can edit a homegroup""" row_count = db.create_homegroup('Fake', 'Fake Location', 'Fake Description', None, None) homegroup_id = db.recent_homegroup()['id'] row_count = db.edit_homegroup(homegroup_id, 'Test HomeGroup', 'Test Location', 'Test Description', None, None) test_hg = db.find_homegroup(homegroup_id) self.assertIsNotNone(test_hg) self.assertEqual(test_hg['Name'], 'Test HomeGroup') self.assertEqual(test_hg['Location'], 'Test Location') self.assertEqual(test_hg['Description'], 'Test Description')
def create_homegroup(): new_homegroup = CreateHomeGroupForm() if request.method == "POST" and new_homegroup.validate(): name = new_homegroup.name.data location = new_homegroup.location.data description = new_homegroup.description.data latitude = new_homegroup.latitude.data longitude = new_homegroup.longitude.data rowcount = db.create_homegroup(name, location, description, latitude, longitude) if rowcount == 1: flash("Homegroup {} Created!".format(new_homegroup.name.data)) return redirect(url_for('get_homegroups')) return render_template('create_homegroup.html', form=new_homegroup)
def create_homegroup(): return db.create_homegroup('Test Home Group', 'Test Location', 'Test Description', -3, -78)