Ejemplo n.º 1
0
def get_callback_params_for_assessment(json_file_dir):
    '''
    '''
    emailnotification = None
    try:
        callback_url = get_value_from_json(json_file_dir, Constants.SOURCE_CALLBACKURL)
        emailnotification = get_value_from_json(json_file_dir, Constants.EMAIL_NOTIFICATION)
    except KeyError:
        logger.error('Assessment is not configured for callback notification')
    return callback_url, emailnotification
Ejemplo n.º 2
0
 def test_missing_nested_keys(self):
     shutil.copy(
         os.path.join(self.data_dir, 'test_valid_content_type.json'),
         self.test_expanded_dir)
     value = get_value_from_json(self.test_expanded_dir,
                                 'source.incorrectkey1.incorrectkey2')
     self.assertEqual(None, value)
Ejemplo n.º 3
0
 def test_get_nested_keys(self):
     shutil.copy(
         os.path.join(self.data_dir, 'test_valid_content_type.json'),
         self.test_expanded_dir)
     key = get_value_from_json(self.test_expanded_dir,
                               'source.testregcallbackurl')
     self.assertEqual('StateTestReg.gov/StuReg/CallBack', key)
Ejemplo n.º 4
0
 def test_missing_from_top_level_key(self):
     shutil.copy(
         os.path.join(self.data_dir,
                      'test_missing_top_level_content_type.json'),
         self.test_expanded_dir)
     value = get_value_from_json(self.test_expanded_dir, 'content')
     self.assertEqual(None, value)
Ejemplo n.º 5
0
    def test_get_from_valid_json(self):
        shutil.copy(
            os.path.join(self.data_dir, 'test_valid_content_type.json'),
            self.test_expanded_dir)
        value = get_value_from_json(self.test_expanded_dir, 'content').lower()

        self.assertEqual('studentregistration', value)
Ejemplo n.º 6
0
def get_assessment_type(json_file_dir):
    """
    Get the assessment type for the UDL job from the json file
    @param json_file_dir: A directory that houses the json file
    @return: UDL job assessment type
    @rtype: string
    """
    assessment_types = Constants.ASSESSMENT_TYPES()
    assessment_type = get_value_from_json(json_file_dir,
                                          Constants.ASSESSMENT_TYPE_KEY)
    if assessment_type not in assessment_types:
        raise ValueError('No valid load type specified in json file --')
    return assessment_type
Ejemplo n.º 7
0
def get_callback_params_for_studentregistration(json_file_dir):
    """
    Get the callback parameter for this UDL job from the json file

    @param json_file_dir: A directory that houses the json file
    @param load_type: The key path of an attribute in a nested json structure

    @return: the callback parameter
    @rtype: string
    """
    student_reg_guid = None
    reg_system_id = None
    callback_url = None

    try:
        student_reg_guid = get_value_from_json(json_file_dir, Constants.IDENTIFICATION_GUID)
        reg_system_id = get_value_from_json(json_file_dir, Constants.SOURCE_TESTREGSYSID)
        callback_url = get_value_from_json(json_file_dir, Constants.SOURCE_TESTREGCALLBACKURL)
        emailnotification = get_value_from_json(json_file_dir, Constants.EMAIL_NOTIFICATION)

    except KeyError:
        logger.error('Student Registration is not configured for callback notification')

    return student_reg_guid, reg_system_id, callback_url, emailnotification
Ejemplo n.º 8
0
def get_load_type(json_file_dir):
    """
    Get the load type for this UDL job from the json file
    @param json_file_dir: A directory that houses the json file
    @return: UDL job load type
    @rtype: string
    """

    load_type = get_value_from_json(json_file_dir,
                                    Constants.LOAD_TYPE_KEY).lower()

    if load_type not in load_types:
        raise ValueError('No valid load type specified in json file --')

    return load_type
Ejemplo n.º 9
0
def get_academic_year_param(json_file_dir):
    """
    Get the academic year parameter from the json file for this job

    @param json_file_dir: A directory that houses the json file

    @return: the academic year parameter
    @rtype: string
    """
    academic_year = None
    try:
        academic_year = get_value_from_json(json_file_dir, Constants.IDENTIFICATION_ACADEMICYEAR)

    except KeyError:
        logger.error('Not configured for academic year')

    if academic_year:
        return int(academic_year)
    else:
        return academic_year
Ejemplo n.º 10
0
 def test_get_empty_json(self):
     open(os.path.join(self.test_expanded_dir, 'test_empty.json'),
          'a').close()
     value = get_value_from_json(self.test_expanded_dir, 'content')
     self.assertEqual(None, value)
Ejemplo n.º 11
0
 def test_malformed_json(self):
     shutil.copy(os.path.join(self.data_dir, 'test_malformed.json'),
                 self.test_expanded_dir)
     value = get_value_from_json(self.test_expanded_dir, 'content')
     self.assertEqual(None, value)