def test_auth_params_provided_in_mongo_url(self): self.app.config['MONGO1_URL'] = \ 'mongodb://%s:%s@%s:%s' % (MONGO1_USERNAME, MONGO1_PASSWORD, MONGO_HOST, MONGO_PORT) with self.app.app_context(): db = PyMongo(self.app, 'MONGO1').db self.assertEquals(0, db.works.count())
def test_auth_params_provided_in_mongo_url(self): self.app.config["MONGO1_URL"] = "mongodb://%s:%s@%s:%s" % ( MONGO1_USERNAME, MONGO1_PASSWORD, MONGO_HOST, MONGO_PORT, ) with self.app.app_context(): db = PyMongo(self.app, "MONGO1").db self.assertEqual(0, db.works.count())
def _pymongo_instance(self): with self.app.app_context(): PyMongo(self.app, "MONGO1")
def test_valid_port(self): self.app.config["MONGO1_PORT"] = 27017 with self.app.app_context(): db = PyMongo(self.app, "MONGO1").db self.assertEqual(0, db.works.count())
def test_auth_params_provided_in_config(self): self.app.config["MONGO1_USERNAME"] = MONGO1_USERNAME self.app.config["MONGO1_PASSWORD"] = MONGO1_PASSWORD with self.app.app_context(): db = PyMongo(self.app, "MONGO1").db self.assertEqual(0, db.works.count())
from bson import ObjectId # For ObjectId to work from eve.io.mongo.flask_pymongo import PyMongo from flask import Flask, redirect, render_template, request, url_for from flask_pymongo import PyMongo from prettytable import from_html from pymongo import MongoClient from pymongo.collection import Collection from werkzeug.debug.tbtools import render_console_html import scrape_mars # Create an instance of Flask app = Flask(__name__) # Use PyMongo to establish Mongo connection mongo = PyMongo(app, uri="mongodb://*****:*****@app.route('/') def index(): output_dict = mongo.db.output_dict.find_one() # renderOut = list(mongo.db.collection.find_one()) # print(data_db) landImage = "static/mission_to_mars.png" return render_template('index.html', output_dict=output_dict)
def func(): with self.app.app_context(): db = PyMongo(self.app, "MONGO1").db db.works.find_one()