# Path: rpaas/api.py
# SENTRY_DSN = os.environ.get("SENTRY_DSN")
# def plans(name=None):
# def flavors(name=None):
# def add_instance():
# def update_instance(name):
# def remove_instance(name):
# def bind(name):
# def unbind(name):
# def bind_unit(name):
# def unbind_unit(name):
# def info(name):
# def node_status(name):
# def status(name):
# def scale_instance(name):
# def restore_machine(name):
# def cancel_restore_machine(name):
# def update_certificate(name):
# def add_route(name):
# def delete_route(name):
# def list_routes(name):
# def add_block(name):
# def delete_block(name, block_name):
# def list_block(name):
# def purge_location(name):
# def purge_bulk_location(name):
# def add_https(name):
# def add_lua(name):
# def list_lua(name):
# def delete_lua(name):
# def get_plugin():
# def get_admin_plugin():
# def main():
# 
# Path: rpaas/storage.py
# class InstanceNotFoundError(Exception):
# class PlanNotFoundError(Exception):
# class FlavorNotFoundError(Exception):
# class DuplicateError(Exception):
# class MongoDBStorage(storage.MongoDBStorage):
#     def store_hc(self, hc):
#     def retrieve_hc(self, name):
#     def remove_hc(self, name):
#     def store_healing(self, instance, machine):
#     def update_healing(self, id, status):
#     def list_healings(self, quantity):
#     def store_task(self, name):
#     def remove_task(self, query):
#     def update_task(self, name, task_id_or_spec):
#     def find_task(self, query):
#     def store_instance_metadata(self, instance_name, **data):
#     def find_instance_metadata(self, instance_name):
#     def find_host_id(self, name):
#     def remove_instance_metadata(self, instance_name):
#     def store_plan(self, plan):
#     def update_plan(self, name, description=None, config=None):
#     def delete_plan(self, name):
#     def find_plan(self, name):
#     def list_plans(self):
#     def _plan_from_dict(self, dict):
#     def store_flavor(self, flavor):
#     def update_flavor(self, name, description=None, config=None):
#     def delete_flavor(self, name):
#     def find_flavor(self, name):
#     def list_flavors(self):
#     def _flavor_from_dict(self, dict):
#     def store_binding(self, name, app_host, app_host_only=False):
#     def remove_binding(self, name):
#     def remove_root_binding(self, name, remove_root_binding_path):
#     def find_binding(self, name):
#     def replace_binding_path(self, name, path, destination=None, content=None, https_only=False):
#     def delete_binding_path(self, name, path):
#     def set_team_quota(self, teamname, quota):
#     def find_team_quota(self, teamname):
#     def _find_team_quota(self, teamname):
#     def increment_quota(self, teamname, prev_used, servicename):
#     def decrement_quota(self, servicename):
#     def store_le_certificate(self, name, domain):
#     def remove_le_certificate(self, name, domain):
#     def find_le_certificates(self, query):
# 
# Path: rpaas/admin_api.py
# def healings():
# def create_plan():
# def retrieve_plan(name):
# def update_plan(name):
# def delete_plan(name):
# def create_flavor():
# def retrieve_flavor(name):
# def update_flavor(name):
# def delete_flavor(name):
# def view_team_quota(team_name):
# def set_team_quota(team_name):
# def restore_instance():
# def register_views(app, list_plans, list_flavors):


import datetime
import json
import unittest
import os
from bson import json_util
from rpaas import api, storage, admin_api
from . import managers
    def test_update_plan_not_found(self):
        config = json.dumps({
            "serviceofferingid": "abcdef1234",
            "NAME": "super",
        })
        resp = self.api.put("/admin/plans/small", data={"description": "small instance",
                                                        "config": config})
        self.assertEqual(404, resp.status_code)
        self.assertEqual("plan not found", resp.data)

    def test_delete_plan(self):
        self.storage.db[self.storage.plans_collection].insert(
            {"_id": "small",
             "description": "some cool plan",
             "config": {"serviceofferingid": "abcdef123456"}}
        )
        resp = self.api.delete("/admin/plans/small")
        self.assertEqual(200, resp.status_code)
        with self.assertRaises(storage.PlanNotFoundError):
            self.storage.find_plan("small")

    def test_delete_plan_not_found(self):
        resp = self.api.delete("/admin/plans/small")
        self.assertEqual(404, resp.status_code)
        self.assertEqual("plan not found", resp.data)

    def test_list_flavors(self):
        resp = self.api.get("/admin/flavors")
        self.assertEqual(200, resp.status_code)
        self.assertEqual("[]", resp.data)

# Path: rpaas/api.py
# SENTRY_DSN = os.environ.get("SENTRY_DSN")
# def plans(name=None):
# def flavors(name=None):
# def add_instance():
# def update_instance(name):
# def remove_instance(name):
# def bind(name):
# def unbind(name):
# def bind_unit(name):
# def unbind_unit(name):
# def info(name):
# def node_status(name):
# def status(name):
# def scale_instance(name):
# def restore_machine(name):
# def cancel_restore_machine(name):
# def update_certificate(name):
# def add_route(name):
# def delete_route(name):
# def list_routes(name):
# def add_block(name):
# def delete_block(name, block_name):
# def list_block(name):
# def purge_location(name):
# def purge_bulk_location(name):
# def add_https(name):
# def add_lua(name):
# def list_lua(name):
# def delete_lua(name):
# def get_plugin():
# def get_admin_plugin():
# def main():
# 
# Path: rpaas/storage.py
# class InstanceNotFoundError(Exception):
# class PlanNotFoundError(Exception):
# class FlavorNotFoundError(Exception):
# class DuplicateError(Exception):
# class MongoDBStorage(storage.MongoDBStorage):
#     def store_hc(self, hc):
#     def retrieve_hc(self, name):
#     def remove_hc(self, name):
#     def store_healing(self, instance, machine):
#     def update_healing(self, id, status):
#     def list_healings(self, quantity):
#     def store_task(self, name):
#     def remove_task(self, query):
#     def update_task(self, name, task_id_or_spec):
#     def find_task(self, query):
#     def store_instance_metadata(self, instance_name, **data):
#     def find_instance_metadata(self, instance_name):
#     def find_host_id(self, name):
#     def remove_instance_metadata(self, instance_name):
#     def store_plan(self, plan):
#     def update_plan(self, name, description=None, config=None):
#     def delete_plan(self, name):
#     def find_plan(self, name):
#     def list_plans(self):
#     def _plan_from_dict(self, dict):
#     def store_flavor(self, flavor):
#     def update_flavor(self, name, description=None, config=None):
#     def delete_flavor(self, name):
#     def find_flavor(self, name):
#     def list_flavors(self):
#     def _flavor_from_dict(self, dict):
#     def store_binding(self, name, app_host, app_host_only=False):
#     def remove_binding(self, name):
#     def remove_root_binding(self, name, remove_root_binding_path):
#     def find_binding(self, name):
#     def replace_binding_path(self, name, path, destination=None, content=None, https_only=False):
#     def delete_binding_path(self, name, path):
#     def set_team_quota(self, teamname, quota):
#     def find_team_quota(self, teamname):
#     def _find_team_quota(self, teamname):
#     def increment_quota(self, teamname, prev_used, servicename):
#     def decrement_quota(self, servicename):
#     def store_le_certificate(self, name, domain):
#     def remove_le_certificate(self, name, domain):
#     def find_le_certificates(self, query):
# 
# Path: rpaas/admin_api.py
# def healings():
# def create_plan():
# def retrieve_plan(name):
# def update_plan(name):
# def delete_plan(name):
# def create_flavor():
# def retrieve_flavor(name):
# def update_flavor(name):
# def delete_flavor(name):
# def view_team_quota(team_name):
# def set_team_quota(team_name):
# def restore_instance():
# def register_views(app, list_plans, list_flavors):


# Path: tests/test_admin_api.py
import datetime
import json
import unittest
import os
from bson import json_util
from rpaas import api, storage, admin_api
from . import managers

    def test_update_plan_not_found(self):
        config = json.dumps({
            "serviceofferingid": "abcdef1234",
            "NAME": "super",
        })
        resp = self.api.put("/admin/plans/small", data={"description": "small instance",
                                                        "config": config})
        self.assertEqual(404, resp.status_code)
        self.assertEqual("plan not found", resp.data)

    def test_delete_plan(self):
        self.storage.db[self.storage.plans_collection].insert(
            {"_id": "small",
             "description": "some cool plan",
             "config": {"serviceofferingid": "abcdef123456"}}
        )
        resp = self.api.delete("/admin/plans/small")
        self.assertEqual(200, resp.status_code)
        with self.assertRaises(storage.PlanNotFoundError):
            self.storage.find_plan("small")

    def test_delete_plan_not_found(self):
        resp = self.api.delete("/admin/plans/small")
        self.assertEqual(404, resp.status_code)
        self.assertEqual("plan not found", resp.data)

    def test_list_flavors(self):
        resp = self.api.get("/admin/flavors")
        self.assertEqual(200, resp.status_code)
        self.assertEqual("[]", resp.data)

        self.storage.db[self.storage.flavors_collection].insert(