예제 #1
0
    def test_profile_get_by_name_diff_project(self):
        profile_name = "my_best_profile"
        shared.create_profile(self.ctx, name=profile_name)

        new_ctx = utils.dummy_context(project="a-different-project")
        res = db_api.profile_get_by_name(new_ctx, profile_name)
        self.assertIsNone(res)

        res = db_api.profile_get_by_name(new_ctx, profile_name, project_safe=False)
        self.assertIsNotNone(res)
        self.assertEqual(profile_name, res.name)
예제 #2
0
    def test_profile_get_by_name_diff_project(self):
        profile_name = 'my_best_profile'
        shared.create_profile(self.ctx, name=profile_name)

        new_ctx = utils.dummy_context(project='a-different-project')
        res = db_api.profile_get_by_name(new_ctx, profile_name)
        self.assertIsNone(res)

        res = db_api.profile_get_by_name(new_ctx,
                                         profile_name,
                                         project_safe=False)
        self.assertIsNotNone(res)
        self.assertEqual(profile_name, res.name)
예제 #3
0
    def test_profile_get_by_name(self):
        profile_name = 'my_best_profile'

        # before creation
        profile = db_api.profile_get_by_name(self.ctx, profile_name)
        self.assertIsNone(profile)

        profile = shared.create_profile(self.ctx, name=profile_name)

        # after creation
        retobj = db_api.profile_get_by_name(self.ctx, profile_name)
        self.assertIsNotNone(retobj)
        self.assertEqual(profile_name, retobj.name)

        # bad name
        retobj = db_api.profile_get_by_name(self.ctx, 'non-exist')
        self.assertIsNone(retobj)
예제 #4
0
    def test_profile_get_by_name(self):
        profile_name = 'my_best_profile'

        # before creation
        profile = db_api.profile_get_by_name(self.ctx, profile_name)
        self.assertIsNone(profile)

        profile = shared.create_profile(self.ctx, name=profile_name)

        # after creation
        retobj = db_api.profile_get_by_name(self.ctx, profile_name)
        self.assertIsNotNone(retobj)
        self.assertEqual(profile_name, retobj.name)

        # bad name
        retobj = db_api.profile_get_by_name(self.ctx, 'non-exist')
        self.assertIsNone(retobj)
예제 #5
0
    def test_profile_get_by_name_show_deleted(self):
        profile_name = "my_best_profile"

        profile_id = shared.create_profile(self.ctx, name=profile_name).id

        db_api.profile_delete(self.ctx, profile_id)

        # default case
        profile = db_api.profile_get_by_name(self.ctx, profile_name)
        self.assertIsNone(profile)

        # explicit false
        profile = db_api.profile_get_by_name(self.ctx, profile_name, show_deleted=False)
        self.assertIsNone(profile)

        # explicit true
        profile = db_api.profile_get_by_name(self.ctx, profile_name, show_deleted=True)
        self.assertIsNotNone(profile)
        self.assertEqual(profile_id, profile.id)
예제 #6
0
    def test_profile_get_by_name(self):
        profile_name = 'my_best_profile'

        # before creation
        profile = db_api.profile_get_by_name(self.ctx, profile_name)
        self.assertIsNone(profile)

        profile = shared.create_profile(self.ctx, name=profile_name)

        # after creation
        retobj = db_api.profile_get_by_name(self.ctx, profile_name)
        self.assertIsNotNone(retobj)
        self.assertEqual(profile_name, retobj.name)

        # bad name
        retobj = db_api.profile_get_by_name(self.ctx, 'non-exist')
        self.assertIsNone(retobj)

        # duplicated name
        shared.create_profile(self.ctx, name=profile_name)
        self.assertRaises(exception.MultipleChoices,
                          db_api.profile_get_by_name, self.ctx, profile_name)
예제 #7
0
    def test_profile_get_by_name_show_deleted(self):
        profile_name = 'my_best_profile'

        profile_id = shared.create_profile(self.ctx, name=profile_name).id

        db_api.profile_delete(self.ctx, profile_id)

        # default case
        profile = db_api.profile_get_by_name(self.ctx, profile_name)
        self.assertIsNone(profile)

        # explicit false
        profile = db_api.profile_get_by_name(self.ctx,
                                             profile_name,
                                             show_deleted=False)
        self.assertIsNone(profile)

        # explicit true
        profile = db_api.profile_get_by_name(self.ctx,
                                             profile_name,
                                             show_deleted=True)
        self.assertIsNotNone(profile)
        self.assertEqual(profile_id, profile.id)