'Test every single function in course_metadata_utils.'

def test_course_metadata_utils(self):

    def mock_strftime_localized(date_time, format_string):
        '\n                                                Mock    version    of    strftime_localized    used    for    testing    purposes.\n\n                                                Because    we    don\'t    have    a    real    implementation    of    strftime_localized\n                                                to    work    with    (strftime_localized    is    provided    by    the    XBlock    runtime,\n                                                which    we    don\'t    have    access    to    for    this    test    case),    we    must    declare\n                                                this    dummy    implementation.    This    does    NOT    behave    like    a    real\n                                                strftime_localized    should.    It    purposely    returns    a    really    dumb    value\n                                                that\'s    only    useful    for    testing    purposes.\n\n                                                Arguments:\n                                                                date_time    (datetime):    datetime    to    be    formatted.\n                                                                format_string    (str):    format    specifier.    Valid    values    include:\n                                                                                -    \'DATE_TIME\'\n                                                                                -    \'TIME\'\n                                                                                -    \'SHORT_DATE\'\n                                                                                -    \'LONG_DATE\'\n\n                                                Returns    (str):    format_string    +    "    "    +    str(date_time)\n                                                '
        if (format_string in ['DATE_TIME', 'TIME', 'SHORT_DATE', 'LONG_DATE']):
            return ((format_string + '    ') + date_time.strftime('%Y-%m-%d    %H:%M:%S'))
        else:
            raise ValueError(('Invalid    format    string    :' + format_string))
    def noop_gettext(text):
        "Dummy    implementation    of    gettext,    so    we    don't    need    Django."
        return text
    test_datetime = datetime(1945, 2, 6, 4, 20, 0, tzinfo=utc)
    advertised_start_parsable = '2038-01-19    03:14:07'
    FunctionTest = namedtuple('FunctionTest', 'function    scenarios')
    TestScenario = namedtuple('TestScenario', 'arguments    expected_return')
    function_tests = [FunctionTest(clean_course_key, [TestScenario((self.demo_course.id, '='), 'course_MVSFQL2EMVWW6WBOGEXUMYLMNRPTEMBRGQ======'), TestScenario((self.html_course.id, '~'), 'course_MNXXK4TTMUWXMMJ2KVXGS5TFOJZWS5DZLAVUGUZNGIYDGK2ZGIYDSNQ~')]), FunctionTest(url_name_for_block, [TestScenario((self.demo_course,), self.demo_course.location.name), TestScenario((self.html_course,), self.html_course.location.name)]), FunctionTest(display_name_with_default_escaped, [TestScenario((self.demo_course,), 'Empty'), TestScenario((self.html_course,), 'Intro    to    &lt;html&gt;')]), FunctionTest(display_name_with_default, [TestScenario((self.demo_course,), 'Empty'), TestScenario((self.html_course,), 'Intro    to    <html>')]), FunctionTest(number_for_course_location, [TestScenario((self.demo_course.location,), 'DemoX.1'), TestScenario((self.html_course.location,), 'CS-203')]), FunctionTest(has_course_started, [TestScenario((self.demo_course.start,), True), TestScenario((self.html_course.start,), False)]), FunctionTest(has_course_ended, [TestScenario((self.demo_course.end,), True), TestScenario((self.html_course.end,), False)]), FunctionTest(course_start_date_is_default, [TestScenario((test_datetime, advertised_start_parsable), False), TestScenario((test_datetime, None), False), TestScenario((DEFAULT_START_DATE, advertised_start_parsable), False), TestScenario((DEFAULT_START_DATE, None), True)]), FunctionTest(may_certify_for_course, [TestScenario(('early_with_info', True, True), True), TestScenario(('early_no_info', False, False), True), TestScenario(('end', True, False), True), TestScenario(('end', False, True), True), TestScenario(('end', False, False), False)])]
    for function_test in function_tests:
        for scenario in function_test.scenarios:
            actual_return = function_test.function(*scenario.arguments)
            self.assertEqual(actual_return, scenario.expected_return)
    with self.assertRaises(ValueError):
        mock_strftime_localized(test_datetime, 'BAD_FORMAT_SPECIFIER')
