def test_update_calls_profiler_update_profile(self):
        """
        Assert that the update() method calls the profiler update_profile() method.
        """
        self.populate()
        profile_manager = ProfileManager()

        profile_manager.update(self.CONSUMER_ID, self.TYPE_1, self.PROFILE_1)

        consumer_manager = ConsumerManager()
        consumer = consumer_manager.get_consumer(self.CONSUMER_ID)
        # The profiler should have been called once with the consumer, content_type, profile, and
        # and empty config (our MockProfile has an empty config)
        mock_plugins.MOCK_PROFILER.update_profile.assert_called_once_with(consumer, self.TYPE_1, self.PROFILE_1, {})
Example #2
0
    def test_update_calls_profiler_update_profile(self):
        """
        Assert that the update() method calls the profiler update_profile() method.
        """
        self.populate()
        profile_manager = ProfileManager()

        profile_manager.update(self.CONSUMER_ID, self.TYPE_1, self.PROFILE_1)

        consumer_manager = ConsumerManager()
        consumer = consumer_manager.get_consumer(self.CONSUMER_ID)
        # The profiler should have been called once with the consumer, content_type, profile, and
        # and empty config (our MockProfile has an empty config)
        mock_plugins.MOCK_PROFILER.update_profile.assert_called_once_with(
            consumer, self.TYPE_1, self.PROFILE_1, {})
    def test_update_with_content_type_without_profiler(self, update_profile):
        """
        Test the update() call with a content_type for which there isn't a Profiler. The method
        should instantiate the baseclass Profiler with an empty config.
        """
        self.populate()
        profile_manager = ProfileManager()
        untype = "non_existing_type_doesnt_exist"

        profile_manager.update(self.CONSUMER_ID, untype, self.PROFILE_1)

        consumer_manager = ConsumerManager()
        consumer = consumer_manager.get_consumer(self.CONSUMER_ID)
        # The profiler should have been called once with the consumer, content_type, profile, and
        # and empty config (our MockProfile has an empty config)
        self.assertEqual(mock_plugins.MOCK_PROFILER.update_profile.call_count, 0)
        # The profiler should be the first parameter (self) passed to update_profile, and we need it
        # to assert that the correct call was made with update_profile
        profiler = update_profile.mock_calls[0][1][0]
        update_profile.assert_called_once_with(profiler, consumer, untype, self.PROFILE_1, {})
Example #4
0
    def test_update_with_content_type_without_profiler(self, update_profile):
        """
        Test the update() call with a content_type for which there isn't a Profiler. The method
        should instantiate the baseclass Profiler with an empty config.
        """
        self.populate()
        profile_manager = ProfileManager()
        untype = 'non_existing_type_doesnt_exist'

        profile_manager.update(self.CONSUMER_ID, untype, self.PROFILE_1)

        consumer_manager = ConsumerManager()
        consumer = consumer_manager.get_consumer(self.CONSUMER_ID)
        # The profiler should have been called once with the consumer, content_type, profile, and
        # and empty config (our MockProfile has an empty config)
        self.assertEqual(mock_plugins.MOCK_PROFILER.update_profile.call_count, 0)
        # The profiler should be the first parameter (self) passed to update_profile, and we need it
        # to assert that the correct call was made with update_profile
        profiler = update_profile.mock_calls[0][1][0]
        update_profile.assert_called_once_with(profiler, consumer, untype,
                                               self.PROFILE_1, {})