예제 #1
0
    def test_as_dict(self):
        objects.load()
        if self.data is None:
            s = planmodel.Plan()
            self.data = {}
        else:
            s = planmodel.Plan(**self.data)
        if 'uri' in self.data:
            del self.data['uri']
        if 'type' in self.data:
            del self.data['type']

        self.assertEqual(self.data, s.as_dict(objects.registry.Plan))
예제 #2
0
파일: test_types.py 프로젝트: alex/solum
 def test_as_dict_from_keys(self):
     data = {
         'name': 'test_hb',
         'project_id': 'a3266ef8-b3fa-4ab8-b468-d42b5fab5c4d'
     }
     p = plan_api.Plan(**data)
     self.assertEqual(data, p.as_dict_from_keys(['name', 'project_id']))
예제 #3
0
 def test_as_dict(self):
     data = {'name': 'test_hb',
             'uri': 'http://test_host/v1/plans/hb',
             'project_id': 'a3266ef8-b3fa-4ab8-b468-d42b5fab5c4d',
             'user_id': '59a9da1f-9a19-4f1e-8877-120865da716b'}
     p = plan_api.Plan(**data)
     del data['uri']
     self.assertEqual(data, p.as_dict(plan_model.Plan))
예제 #4
0
파일: plan.py 프로젝트: maniacs-ops/solum
def init_plan_v1(yml_input_plan):
    if not yml_input_plan.get('name'):
        raise exception.BadRequest(reason="Name field is missing.")
    try:
        pp = plan.Plan(**yml_input_plan)
    except ValueError as ve:
        raise exception.BadRequest(reason=six.text_type(ve))
    try:
        name_regex = re.compile(r'^([a-zA-Z0-9-_]{1,100})$')
        assert name_regex.match(pp.name), 'Plan name is invalid.'
    except AssertionError as ae:
        raise exception.BadRequest(reason=six.text_type(ae))
    return pp
예제 #5
0
def init_plan_v1(yml_input_plan):
    plan_handler_v1 = plan_handler.PlanHandler(pecan.request.security_context)
    plan_v1 = plan.Plan(**yml_input_plan)
    return plan_handler_v1, plan_v1