Example #1
0
    def test_validate_function_valid(self):
        """
        Tests the validation of a valid 5GTANGO function.
        """
        functions_path = os.path.join(SAMPLES_DIR, 'functions', 'valid-son')
        validator = Validator()
        validator.configure(syntax=True, integrity=True, topology=True)
        validator.validate_function(functions_path)

        self.assertEqual(validator.error_count, 0)
        self.assertEqual(validator.warning_count, 0)
Example #2
0
    def test_validate_function_integrity_invalid(self):
        """
        Tests the incorrect validation of a function integrity.
        """
        functions_path = os.path.join(SAMPLES_DIR, 'functions',
                                      'invalid_integrity-son')
        validator = Validator()
        validator.configure(syntax=True, integrity=True, topology=False)
        validator.validate_function(functions_path)

        self.assertEqual(validator.error_count, 3)
        self.assertEqual(validator.warning_count, 0)
Example #3
0
    def test_validate_service_syntax_valid_simplest_nsd(self):
        """
        Tests the correct validation of a service syntax simplest nsd
        """
        service_path = os.path.join(SAMPLES_DIR, 'services',
                                    'valid-syntax-tng', 'simplest-example.yml')

        validator = Validator()
        validator.configure(syntax=True, integrity=False, topology=False)
        validator.validate_service(service_path)

        self.assertEqual(validator.error_count, 0)
        self.assertEqual(validator.warning_count, 0)
Example #4
0
    def test_validate_service_syntax_invalid_required_properties(self):
        """
        Tests the incorrect validation of a service syntax with \
        required field in the nsd
        """
        service_path = os.path.join(SAMPLES_DIR, 'services',
                                    'invalid-syntax-tng',
                                    'required_properties.yml')

        validator = Validator()
        validator.configure(syntax=True, integrity=False, topology=False)
        validator.validate_service(service_path)

        self.assertEqual(validator.error_count, 1)
        self.assertEqual(validator.warning_count, 0)
Example #5
0
    def test_validate_service_syntax_nonexistent_descriptor(self):
        """
        Tests the incorrect validation of a service syntax with \
        a unexpected field in the nsd
        """
        service_path = os.path.join(SAMPLES_DIR, 'services',
                                    'invalid-syntax-tng',
                                    'unexpected_field.yml')

        validator = Validator()
        validator.configure(syntax=True, integrity=False, topology=False)
        validator.validate_service(service_path)

        self.assertEqual(validator.error_count, 1)
        self.assertEqual(validator.warning_count, 0)
Example #6
0
    def test_validate_service_topology_valid(self):
        """
        Tests the correct validation of a service topology
        """
        service_path = os.path.join(SAMPLES_DIR, 'services', 'valid-son',
                                    'valid.yml')
        functions_path = os.path.join(SAMPLES_DIR, 'functions', 'valid-son')
        validator = Validator()
        validator.configure(syntax=True,
                            integrity=True,
                            topology=True,
                            dpath=functions_path)
        validator.validate_service(service_path)

        self.assertEqual(validator.error_count, 0)
        self.assertEqual(validator.warning_count, 0)