def test_get_one(self): doc = make_doc() doc2 = make_doc(2) update_data(self.ds, doc) update_data(self.ds, doc2) ds = Datastore() item = ds.get_one(filter={'_id': doc['_id']}) self.assertEqual(item, doc)
def doc_needs_update(key): """ Determine if a doc in database needs an update. :param key: document key :rtype: boolean """ _id = _get_id(key) ds = Datastore() result = ds.get_one({'_id': _id}) if result and result.get('etag') == key.etag: return False return True
def bundle_view(key=None): if not key: return render_template('404.html', e='Bundle not found.'), 404 ds = Datastore() cwr_result = ds.get_one({'_id': key}) if not cwr_result: return render_template('404.html', e='Bundle not found.'), 404 bundle = Bundle(cwr_result) svg_path = bundle.svg_path() bundle_name = bundle.name results = bundle.test_result() history = None chart_data = bundle.generate_chart_data() return render_template( 'bundle.html', bundle_name=bundle_name, results=results, svg_path=svg_path, history=history, chart_data=chart_data)