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)
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)
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)
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)