Exemplo n.º 1
0
    def test_get_required_recommended_fields_for_validation(self):
        """Test for Creating list of fields which are Required and
        recommended """

        xisConfig = XISConfiguration(target_schema='p2881_schema.json')
        xisConfig.save()

        req_dict1, rcm_dict2 = \
            get_required_recommended_fields_for_validation()
        self.assertTrue(req_dict1)
        self.assertTrue(rcm_dict2)
Exemplo n.º 2
0
 def test_create_two_xis_configuration(self):
     """Test that trying to create more than one XIS Configuration throws
     ValidationError """
     with self.assertRaises(ValidationError):
         xisConfig = XISConfiguration(target_schema="example1.json")
         xisConfig2 = XISConfiguration(target_schema="example2.json")
         xisConfig.save()
         xisConfig2.save()
Exemplo n.º 3
0
    def test_get_filter_field(self):
        """This test is to check if function returns the filter field"""
        with patch('core.management.utils.xse_client.XISConfiguration.objects'
                   ) as xis_config:
            configObj = XISConfiguration(target_schema="test.json",
                                         xse_host="host:8080",
                                         xse_index="test-index")
            xis_config.first.return_value = configObj
            result = get_filter_field()

            self.assertEquals(result, "provider_name")
Exemplo n.º 4
0
    def test_get_elasticsearch_index(self):
        """This test is to check if function returns the elasticsearch index"""
        with patch('core.management.utils.xse_client.XISConfiguration.objects'
                   ) as xis_config:
            configObj = XISConfiguration(target_schema="test.json",
                                         xse_host="host:8080",
                                         xse_index="test-index")
            xis_config.first.return_value = configObj
            result_api_es_index = get_elasticsearch_index()

            self.assertTrue(result_api_es_index)
Exemplo n.º 5
0
 def test_get_target_validation_schema(self):
     """Test to retrieve target_metadata_schema from XIS configuration"""
     with patch('core.management.utils.xss_client'
                '.XISConfiguration.objects') as xisconfigobj, \
             patch('core.management.utils.xss_client'
                   '.read_json_data') as read_obj:
         xisConfig = XISConfiguration(target_schema='p2881_schema.json')
         xisconfigobj.return_value = xisConfig
         read_obj.return_value = read_obj
         read_obj.return_value = self.target_data_dict
         return_from_function = get_target_validation_schema()
         self.assertEqual(read_obj.return_value, return_from_function)
Exemplo n.º 6
0
    def test_get_autocomplete_field(self):
        """This test is to check if function returns the autocomplete field"""
        with patch('core.management.utils.xse_client.XISConfiguration.objects'
                   ) as xis_config:
            configObj = XISConfiguration(target_schema="test.json",
                                         xse_host="host:8080",
                                         xse_index="test-index")
            xis_config.first.return_value = configObj
            result = get_autocomplete_field()

            self.assertEquals(result,
                              "metadata.Metadata_Ledger.Course.CourseTitle")
Exemplo n.º 7
0
    def test_create_xis_configuration(self):
        """Test that creating a new XIS Configuration entry is successful
        with defaults """
        target_schema = 'test_file.json'
        xse_host = 'test:8080'
        xse_index = 'test-index'

        xisConfig = XISConfiguration(target_schema=target_schema,
                                     xse_host=xse_host,
                                     xse_index=xse_index)

        self.assertEqual(xisConfig.target_schema, target_schema)
        self.assertEqual(xisConfig.xse_host, xse_host)
        self.assertEqual(xisConfig.xse_index, xse_index)