Beispiel #1
0
 def is_available(cls, version):
     _check_version = Version(version)
     if Version(cls.available_since) <= _check_version and Version(
             cls.removed_since
     ) > _check_version and _check_version not in list(
             Version(_v) for _v in cls.unavailable_on):
         return True
     return False
Beispiel #2
0
    def is_available(cls, version, compatiblity_mode=True):
        _check_version = Version(version)
        if Version(cls.available_since) <= _check_version and Version(
                cls.removed_since
        ) > _check_version and _check_version not in list(
                Version(_v) for _v in cls.unavailable_on):
            return True

        if not compatiblity_mode:
            return False

        _compatibility_routes = list(_r for _r in cls.get_subroutes())
        return any(_r.is_available(version) for _r in _compatibility_routes)
Beispiel #3
0
    def __init__(self, username=None, password=None, url=None, token=None, watcher=None):
        # Initiate session with HyperCube server
        self.session = Session(username=username, password=password, token=token, url=url)
        try:
            # We must fetch the System version BEFORE creating route, so this call is hard coded
            _system_details = self.session.request('GET', System._About.path)
            self.session_details = SessionDetails(url=self.session.url,
                                                  name=_system_details.get('name', 'N/A'),
                                                  product=_system_details.get('product', 'N/A'),
                                                  version=_system_details.get('version', 'N/A'),
                                                  hdp_version=_system_details.get('hdpVersion', 0),
                                                  build_date=_system_details.get('buildDate', 'N/A'),
                                                  )
        except Exception:
            self.session_details = SessionDetails(url=url,
                                                  name=None,
                                                  product=None,
                                                  version=None,
                                                  hdp_version=None,
                                                  build_date=None,
                                                  )
        self.session.version = Version(self.session_details.hdp_version)

        # Creating Resources
        self._create_resources(self._resources, watcher=None)
        self._default_timeout_settings = TimeOutSettings()
Beispiel #4
0
    def test_schemas(self):
        _path = pathlib.Path(__file__)
        for _file in _path.parent.joinpath('data', 'schema_json').iterdir():
            _file_name = _file.parts[-1]
            if not _file_name.endswith('.json'):
                continue

            with open(_file, 'r', encoding="utf-8") as F:
                schema = json.load(F)

            version = Version(schema.get('version'))
            results = Router.validate_schema(schema, version)

            message = '\n' + json.dumps(results, sort_keys=True, indent=4)

            # Empty sets evaluates to False so assertFalse checks empty
            self.assertFalse(
                results.get('unexpected_resources'),
                f'{_file_name} - Resources not present in the schema{message}')
            self.assertFalse(
                results.get('missing_resources'),
                f'{_file_name}Resources missing in the API{message}')

            for _resource_name, _route_diffs in results.get(
                    'different_resources').items():
                self.assertFalse(
                    _route_diffs.get('unexpected_routes'),
                    f'{_file_name} - Routes not present in the schema for {_resource_name}{message}'
                )
                self.assertFalse(
                    _route_diffs.get('missing_routes'),
                    f'{_file_name} - Routes missing in the API for {_resource_name}{message}'
                )
Beispiel #5
0
    def test_version(self):
        v_naught = Version(0)
        v_null = Version(None)
        v_dev = Version('dev')
        v_major = Version('1')
        v_minor = Version('1.1')
        v_patch = Version('1.1.1')
        v_int = Version(1)
        v_float = Version(1.1)
        v_version = Version(Version('1.1.1'))

        self.assertTrue(v_dev.is_dev)
        self.assertTrue(v_null.is_dev)

        self.assertFalse(v_naught.is_dev)
        self.assertFalse(v_major.is_dev)
        self.assertFalse(v_minor.is_dev)
        self.assertFalse(v_patch.is_dev)
        self.assertFalse(v_int.is_dev)
        self.assertFalse(v_float.is_dev)
        self.assertFalse(v_version.is_dev)

        self.assertTrue(v_naught < v_null)
        self.assertFalse(v_naught >= v_null)

        self.assertTrue(v_naught < v_dev)
        self.assertFalse(v_naught >= v_dev)

        self.assertTrue(v_major < v_dev)
        self.assertFalse(v_major >= v_dev)

        self.assertTrue(v_major < v_minor)
        self.assertFalse(v_major >= v_minor)

        self.assertTrue(v_minor < v_patch)
        self.assertFalse(v_minor >= v_patch)

        self.assertTrue(v_major == v_int)
        self.assertFalse(v_major != v_int)

        self.assertTrue(v_minor == v_float)
        self.assertFalse(v_minor != v_float)

        self.assertTrue(v_patch == v_version)
        self.assertTrue(v_dev != v_version)
Beispiel #6
0
    def __init__(self,
                 username=None,
                 password=None,
                 url=None,
                 token=None,
                 watcher=None):
        # Initiate session with HyperCube server
        self.session = Session(username=username,
                               password=password,
                               token=token,
                               url=url)
        try:
            # We must fetch the System version BEFORE creating route, so this call is hard coded
            _system_details = self.session.request('GET', System._About.path)
            _version = _system_details.get('hdpVersion', 0)
        except Exception:
            _version = 0
        self.session.version = Version(_version)

        # Creating Resources
        for resourceCls in self._resources:
            self.__setattr__(resourceCls.__name__,
                             resourceCls(self.session, watcher=watcher))
        self._default_timeout_settings = TimeOutSettings()
 def cls_decorator(cls):
     cls.deprecated_since = Version(version)
     return cls
 def cls_decorator(cls):
     cls.available_since = Version(version)
     return cls
 def cls_decorator(cls):
     cls.add_redirection(Version(version), reroute_to, convert_to)
     return cls