def test_blank_data(self, mock_logger_error):
     """
     if data required to build the roster link is missing, we log it and
     return None to indicate to calling procedure that we could not build it
     """
     test_course_instances = [
         {
             'cs_class_number': '56789',
             'term': {'calendar_year': '2016'}
         },
         {
             'cs_class_number': None,
             'term': {'calendar_year': '2016', 'term_code': '2'}
         },
         {
             'cs_class_number': '56789',
             'term': {'term_code': '2'}
         },
         {
             'term': {'calendar_year': '2016', 'term_code': '2'}
         },
     ]
     for test_course_instance in test_course_instances:
         response = _get_roster_url(test_course_instance, self.test_user_id)
         self.assertIsNone(response)
         self.assertEqual(mock_logger_error.call_count, 1)
         mock_logger_error.reset_mock()
    def test_good_data(self, mock_logger_error):
        test_course_instance = {
            'cs_class_number': '56789',
            'term': {'calendar_year': '2016', 'term_code': '2'}
        }

        expected_dynamic_query = self.test_dynamic_query_template.format(
            self.test_user_id,
            test_course_instance['cs_class_number'],
            '2162')
        expected_url = '{}{}'.format(self.test_roster_url_base,
                                     expected_dynamic_query)

        response = _get_roster_url(test_course_instance, self.test_user_id)

        self.assertEqual(response, expected_url)
        self.assertEqual(mock_logger_error.call_count, 0)
예제 #3
0
    def test_good_data(self, mock_logger_error):
        test_course_instance = {
            'cs_class_number': '56789',
            'term': {
                'calendar_year': '2016',
                'term_code': '2'
            }
        }

        expected_dynamic_query = self.test_dynamic_query_template.format(
            self.test_user_id, test_course_instance['cs_class_number'], '2162')
        expected_url = '{}{}'.format(self.test_roster_url_base,
                                     expected_dynamic_query)

        response = _get_roster_url(test_course_instance, self.test_user_id)

        self.assertEqual(response, expected_url)
        self.assertEqual(mock_logger_error.call_count, 0)
예제 #4
0
 def test_blank_data(self, mock_logger_error):
     """
     if data required to build the roster link is missing, we log it and
     return None to indicate to calling procedure that we could not build it
     """
     test_course_instances = [
         {
             'cs_class_number': '56789',
             'term': {
                 'calendar_year': '2016'
             }
         },
         {
             'cs_class_number': None,
             'term': {
                 'calendar_year': '2016',
                 'term_code': '2'
             }
         },
         {
             'cs_class_number': '56789',
             'term': {
                 'term_code': '2'
             }
         },
         {
             'term': {
                 'calendar_year': '2016',
                 'term_code': '2'
             }
         },
     ]
     for test_course_instance in test_course_instances:
         response = _get_roster_url(test_course_instance, self.test_user_id)
         self.assertIsNone(response)
         self.assertEqual(mock_logger_error.call_count, 1)
         mock_logger_error.reset_mock()