Ejemplo n.º 1
0
    def test_validate_package(self):
        creator = ApplicationCreator(self.config, self.environment,
                                     self.service)
        result = {}
        try:
            creator.validate_package(self.package_metadata['package_name'],
                                     self.package_metadata)
        except FailedValidation as ex:
            result = ex.msg

        expected_report = {
            'oozie': {
                'componentA': ['missing file workflow.xml'],
                'componentB': ['missing file workflow.xml']
            },
            'sparkStreaming': {
                'componentC': [
                    'missing file yarn-kill.py',
                    'missing file application.properties',
                    'missing file upstart.conf',
                    'missing file log4j.properties'
                ]
            }
        }
        self.assertEqual(result, expected_report)
    def test_validate_package(self):
        creator = ApplicationCreator(self.config, self.environment, self.service)
        result = {}
        try:
            creator.validate_package(self.package_metadata['package_name'], self.package_metadata)
        except FailedValidation as ex:
            result = ex.msg

        expected_report = {
            'oozie': {
                'componentA': ['missing file workflow.xml'],
                'componentB': ['missing file workflow.xml']},
            'sparkStreaming': {
                'componentC': ['missing file application.properties',
                               'missing file log4j.properties']}}
        self.assertEqual(result, expected_report)
    def test_invalid_package(self):
        creator = ApplicationCreator(self.config, self.environment, self.service)
        try:
            creator.validate_package('test_package-1.0.2a', {"package_name": "test_package-1.0.2"})
            self.assertFail('Expected FailedValidation exception')
        except FailedValidation as ex:
            self.assertEqual(ex.msg, 'package name must match name of enclosed folder but found test_package-1.0.2a and test_package-1.0.2')

        try:
            creator.validate_package('test_package-1.0', {"package_name": "test_package-1.0"})
            self.assertFail('Expected FailedValidation exception')
        except FailedValidation as ex:
            self.assertEqual(ex.msg, 'version must be a three part major.minor.patch e.g. 1.2.3 but found 1.0')

        try:
            creator.validate_package('test_package=1.0.2', {"package_name": "test_package=1.0.2"})
            self.assertFail('Expected FailedValidation exception')
        except FailedValidation as ex:
            self.assertEqual(ex.msg, 'package name must be of the form name-version e.g. name-version.1.2.3 but found test_package=1.0.2')

        creator.validate_package('test-package-1.0.2', {"package_name": "test-package-1.0.2", "component_types": {}})
    def test_invalid_package(self):
        creator = ApplicationCreator(self.config, self.environment,
                                     self.service)
        try:
            creator.validate_package('test_package-1.0.2a',
                                     {"package_name": "test_package-1.0.2"})
            self.assertFail('Expected FailedValidation exception')
        except FailedValidation as ex:
            self.assertEqual(
                ex.msg,
                'package name must match name of enclosed folder but found test_package-1.0.2a and test_package-1.0.2'
            )

        try:
            creator.validate_package('test_package-1.0',
                                     {"package_name": "test_package-1.0"})
            self.assertFail('Expected FailedValidation exception')
        except FailedValidation as ex:
            self.assertEqual(
                ex.msg,
                'version must be a three part major.minor.patch e.g. 1.2.3 but found 1.0'
            )

        try:
            creator.validate_package('test_package=1.0.2',
                                     {"package_name": "test_package=1.0.2"})
            self.assertFail('Expected FailedValidation exception')
        except FailedValidation as ex:
            self.assertEqual(
                ex.msg,
                'package name must be of the form name-version e.g. name-version.1.2.3 but found test_package=1.0.2'
            )

        creator.validate_package('test-package-1.0.2', {
            "package_name": "test-package-1.0.2",
            "component_types": {}
        })