Beispiel #1
0
    def test_get_deferred_content_units_no_model(self, mock_qs, mock_get_model, mock_log):
        # Setup
        mock_unit = Mock(unit_type_id='abc', unit_id='123')
        mock_qs.objects.filter.return_value = [mock_unit]
        mock_get_model.return_value = None

        # Test
        result = list(content_controller._get_deferred_content_units())
        self.assertEqual(0, len(result))
        mock_log.assert_called_once_with('Unable to find the model object for the abc type.')
        mock_get_model.assert_called_once_with('abc')
Beispiel #2
0
    def test_get_deferred_content_units(self, mock_qs, mock_get_model):
        # Setup
        mock_unit = Mock(unit_type_id='abc', unit_id='123')
        mock_qs.objects.filter.return_value = [mock_unit]

        # Test
        result = list(content_controller._get_deferred_content_units())
        self.assertEqual(1, len(result))
        mock_get_model.assert_called_once_with('abc')
        unit_filter = mock_get_model.return_value.objects.filter
        unit_filter.assert_called_once_with(id='123')
        unit_filter.return_value.get.assert_called_once_with()
Beispiel #3
0
    def test_get_deferred_content_units_no_unit(self, mock_qs, mock_get_model, mock_log):
        # Setup
        mock_unit = Mock(unit_type_id='abc', unit_id='123')
        mock_qs.objects.filter.return_value = [mock_unit]
        unit_qs = mock_get_model.return_value.objects.filter.return_value
        unit_qs.get.side_effect = DoesNotExist

        # Test
        result = list(content_controller._get_deferred_content_units())
        self.assertEqual(0, len(result))
        mock_log.assert_called_once_with('Unable to find the abc:123 content unit.')
        mock_get_model.assert_called_once_with('abc')
Beispiel #4
0
    def test_get_deferred_content_units(self, mock_qs, mock_get_model):
        # Setup
        mock_unit = Mock(unit_type_id='abc', unit_id='123')
        mock_qs.objects.filter.return_value = [mock_unit]

        # Test
        result = list(content_controller._get_deferred_content_units())
        self.assertEqual(1, len(result))
        mock_get_model.assert_called_once_with('abc')
        unit_filter = mock_get_model.return_value.objects.filter
        unit_filter.assert_called_once_with(id='123')
        unit_filter.return_value.get.assert_called_once_with()
Beispiel #5
0
    def test_get_deferred_content_units_no_model(self, mock_qs, mock_get_model,
                                                 mock_log):
        # Setup
        mock_unit = Mock(unit_type_id='abc', unit_id='123')
        mock_qs.objects.filter.return_value = [mock_unit]
        mock_get_model.return_value = None

        # Test
        result = list(content_controller._get_deferred_content_units())
        self.assertEqual(0, len(result))
        mock_log.assert_called_once_with(
            'Unable to find the model object for the abc type.')
        mock_get_model.assert_called_once_with('abc')
Beispiel #6
0
    def test_get_deferred_content_units_no_unit(self, mock_qs, mock_get_model,
                                                mock_log):
        # Setup
        mock_unit = Mock(unit_type_id='abc', unit_id='123')
        mock_qs.objects.filter.return_value = [mock_unit]
        unit_qs = mock_get_model.return_value.objects.filter.return_value
        unit_qs.get.side_effect = DoesNotExist

        # Test
        result = list(content_controller._get_deferred_content_units())
        self.assertEqual(0, len(result))
        mock_log.assert_called_once_with(
            'Unable to find the abc:123 content unit.')
        mock_get_model.assert_called_once_with('abc')