Skip to content

Commit

Permalink
Cover with unittests subdomain fatching utility
Browse files Browse the repository at this point in the history
  • Loading branch information
wowkalucky committed Jul 13, 2017
1 parent ee0becb commit 1a4ad5d
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion video_xblock/tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import unittest

from ddt import ddt, data
from django.test.utils import override_settings
from mock import patch, Mock, PropertyMock

from video_xblock.utils import import_from, underscore_to_mixedcase, create_reference_name, normalize_transcripts
from video_xblock.utils import (
import_from, underscore_to_mixedcase, create_reference_name, normalize_transcripts, get_current_microsite_prefix
)


@ddt
Expand Down Expand Up @@ -66,3 +69,36 @@ def test_normalize_transcripts_normal(self):
normalized_transcripts = normalize_transcripts(test_transcripts)
# Assert
self.assertEqual(normalized_transcripts, expected_transcripts)

@override_settings(
# Arrange
USE_MICROSITES=True,
SITE_NAME='foo.domain.name'
)
def test_get_current_microsite_prefix_microsites_enabled_success(self):
# Act
prefix = get_current_microsite_prefix()
# Assert
self.assertEqual(prefix, 'foo')

@override_settings(
# Arrange
USE_MICROSITES=True,
SITE_NAME=None
)
def test_get_current_microsite_prefix_microsites_enabled_failure(self):
# Act
prefix = get_current_microsite_prefix()
# Assert
self.assertIsNone(prefix)

@override_settings(
# Arrange
USE_MICROSITES=False,
SITE_NAME='foo.domain.name'
)
def test_get_current_microsite_prefix_microsites_disabled(self):
# Act
prefix = get_current_microsite_prefix()
# Assert
self.assertIsNone(prefix)

0 comments on commit 1a4ad5d

Please sign in to comment.