# Path: rpaas/plan.py
# class InvalidPlanError(Exception):
# class Plan(object):
#     def __init__(self, field):
#     def __unicode__(self):
#     def __init__(self, name, description, config):
#     def validate(self):
#     def to_dict(self):
# 
# 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/flavor.py
# class InvalidFlavorError(Exception):
# class Flavor(object):
#     def __init__(self, field):
#     def __unicode__(self):
#     def __init__(self, name, description, config):
#     def validate(self):
#     def to_dict(self):


import datetime
import unittest
import os
import freezegun
from rpaas import plan, storage, flavor

    def test_store_plan(self):
        p = plan.Plan(name="super_huge", description="very huge thing",
                      config={"serviceofferingid": "abcdef123"})
        self.storage.store_plan(p)
        got_plan = self.storage.find_plan(p.name)
        self.assertEqual(p.to_dict(), got_plan.to_dict())

    def test_store_plan_duplicate(self):
        p = plan.Plan(name="small", description="small thing",
                      config={"serviceofferingid": "abcdef123"})
        with self.assertRaises(storage.DuplicateError):
            self.storage.store_plan(p)

    def test_update_plan(self):
        p = plan.Plan(name="super_huge", description="very huge thing",
                      config={"serviceofferingid": "abcdef123"})
        self.storage.store_plan(p)
        self.storage.update_plan(p.name, description="wat?",
                                 config={"serviceofferingid": "abcdef123459"})
        p = self.storage.find_plan(p.name)
        self.assertEqual("super_huge", p.name)
        self.assertEqual("wat?", p.description)
        self.assertEqual({"serviceofferingid": "abcdef123459"}, p.config)

    def test_update_plan_partial(self):
        p = plan.Plan(name="super_huge", description="very huge thing",
                      config={"serviceofferingid": "abcdef123"})
        self.storage.store_plan(p)
        self.storage.update_plan(p.name, config={"serviceofferingid": "abcdef123459"})

# Path: rpaas/plan.py
# class InvalidPlanError(Exception):
# class Plan(object):
#     def __init__(self, field):
#     def __unicode__(self):
#     def __init__(self, name, description, config):
#     def validate(self):
#     def to_dict(self):
# 
# 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/flavor.py
# class InvalidFlavorError(Exception):
# class Flavor(object):
#     def __init__(self, field):
#     def __unicode__(self):
#     def __init__(self, name, description, config):
#     def validate(self):
#     def to_dict(self):


# Path: tests/test_storage.py
import datetime
import unittest
import os
import freezegun
from rpaas import plan, storage, flavor


    def test_store_plan(self):
        p = plan.Plan(name="super_huge", description="very huge thing",
                      config={"serviceofferingid": "abcdef123"})
        self.storage.store_plan(p)
        got_plan = self.storage.find_plan(p.name)
        self.assertEqual(p.to_dict(), got_plan.to_dict())

    def test_store_plan_duplicate(self):
        p = plan.Plan(name="small", description="small thing",
                      config={"serviceofferingid": "abcdef123"})
        with self.assertRaises(storage.DuplicateError):
            self.storage.store_plan(p)

    def test_update_plan(self):
        p = plan.Plan(name="super_huge", description="very huge thing",
                      config={"serviceofferingid": "abcdef123"})
        self.storage.store_plan(p)
        self.storage.update_plan(p.name, description="wat?",
                                 config={"serviceofferingid": "abcdef123459"})
        p = self.storage.find_plan(p.name)
        self.assertEqual("super_huge", p.name)
        self.assertEqual("wat?", p.description)
        self.assertEqual({"serviceofferingid": "abcdef123459"}, p.config)

    def test_update_plan_partial(self):
        p = plan.Plan(name="super_huge", description="very huge thing",
                      config={"serviceofferingid": "abcdef123"})
        self.storage.store_plan(p)
        self.storage.update_plan(p.name, config={"serviceofferingid": "abcdef123459"})

        p = self.storage.find_plan(p.name)