def test_provision_mongo(self): """ Provision mongo databases """ instance = OpenEdXInstanceFactory(use_ephemeral_databases=False) instance.provision_mongo() self.check_mongo(instance)
def test_provision_mongo_no_url(self): """ Don't provision any mongo databases if INSTANCE_MONGO_URL is not set """ mongo = pymongo.MongoClient(settings.INSTANCE_MONGO_URL) with override_settings(INSTANCE_MONGO_URL=None): instance = OpenEdXInstanceFactory(use_ephemeral_databases=False) instance.provision_mongo() databases = mongo.database_names() for database in instance.mongo_database_names: self.assertNotIn(database, databases)
def test_provision_mongo_again(self): """ Only create the databases once """ instance = OpenEdXInstanceFactory(use_ephemeral_databases=False) instance.provision_mongo() self.assertIs(instance.mongo_provisioned, True) mongo_user = instance.mongo_user mongo_pass = instance.mongo_pass instance.provision_mongo() self.assertEqual(instance.mongo_user, mongo_user) self.assertEqual(instance.mongo_pass, mongo_pass) self.check_mongo(instance)