Пример #1
0
 def test_get_all_profiles(self):
     objects = pbm.get_all_profiles(self.session)
     test_spec = self.spec.get("test_get_all_profiles")
     expected_profile_names = test_spec.get("profile_names")
     profile_name_list = []
     for one_object in objects:
         profile_name_list.append(one_object.name)
     for one_profile in expected_profile_names:
         self.assertTrue(one_profile in profile_name_list)
Пример #2
0
 def test_get_all_profiles_with_no_profiles(self):
     session = mock.Mock()
     session.pbm = mock.Mock()
     session.invoke_api.return_value = []
     profiles = pbm.get_all_profiles(session)
     session.invoke_api.assert_called_once_with(
         session.pbm,
         'PbmQueryProfile',
         session.pbm.service_content.profileManager,
         resourceType=session.pbm.client.factory.create())
     self.assertEqual([], profiles)
Пример #3
0
    def test_get_all_profiles(self):
        session = mock.Mock()
        session.pbm = mock.Mock()
        profile_ids = mock.Mock()

        def invoke_api_side_effect(module, method, *args, **kwargs):
            self.assertEqual(session.pbm, module)
            self.assertTrue(method in ['PbmQueryProfile',
                                       'PbmRetrieveContent'])
            self.assertEqual(session.pbm.service_content.profileManager,
                             args[0])
            if method == 'PbmQueryProfile':
                self.assertEqual('STORAGE',
                                 kwargs['resourceType'].resourceType)
                return profile_ids
            self.assertEqual(profile_ids, kwargs['profileIds'])

        session.invoke_api.side_effect = invoke_api_side_effect
        pbm.get_all_profiles(session)
        self.assertEqual(2, session.invoke_api.call_count)
Пример #4
0
 def test_get_all_profiles_with_no_profiles(self):
     session = mock.Mock()
     session.pbm = mock.Mock()
     session.invoke_api.return_value = []
     profiles = pbm.get_all_profiles(session)
     session.invoke_api.assert_called_once_with(
         session.pbm,
         'PbmQueryProfile',
         session.pbm.service_content.profileManager,
         resourceType=session.pbm.client.factory.create())
     self.assertEqual([], profiles)
Пример #5
0
    def test_get_all_profiles(self):
        session = mock.Mock()
        session.pbm = mock.Mock()
        profile_ids = mock.Mock()

        def invoke_api_side_effect(module, method, *args, **kwargs):
            self.assertEqual(session.pbm, module)
            self.assertTrue(
                method in ['PbmQueryProfile', 'PbmRetrieveContent'])
            self.assertEqual(session.pbm.service_content.profileManager,
                             args[0])
            if method == 'PbmQueryProfile':
                self.assertEqual('STORAGE',
                                 kwargs['resourceType'].resourceType)
                return profile_ids
            self.assertEqual(profile_ids, kwargs['profileIds'])

        session.invoke_api.side_effect = invoke_api_side_effect
        pbm.get_all_profiles(session)
        self.assertEqual(2, session.invoke_api.call_count)