How to use the mike.versions.Versions function in mike

To help you get started, we’ve selected a few mike examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jimporter / mike / test / unit / test_versions.py View on Github external
def test_remove_version(self):
        versions = Versions()
        versions.add('1.0')
        v = versions.remove('1.0')
        self.assertEqual(v, VersionInfo('1.0'))
        self.assertEqual(list(versions), [])
github jimporter / mike / test / unit / test_versions.py View on Github external
def test_dumps(self):
        versions = Versions()
        versions.add('2.0', '2.0.2', ['latest'])
        versions.add('1.0', '1.0.1', ['stable'])
        self.assertEqual(json.loads(versions.dumps()), [
            {'version': '2.0', 'title': '2.0.2', 'aliases': ['latest']},
            {'version': '1.0', 'title': '1.0.1', 'aliases': ['stable']}
        ])
github jimporter / mike / test / unit / test_versions.py View on Github external
def test_update_alias_aliases(self):
        versions = Versions()
        versions.add('1.0', '1.0.0', ['latest'])
        diff = versions.update('latest', aliases=['greatest'])
        self.assertEqual(diff, {'greatest'})
        self.assertEqual(list(versions), [
            VersionInfo('1.0', '1.0.0', ['latest', 'greatest']),
        ])
github jimporter / mike / test / unit / test_versions.py View on Github external
def test_remove_alias(self):
        versions = Versions()
        versions.add('1.0', aliases=['latest'])
        v = versions.remove('latest')
        self.assertEqual(v, 'latest')
        self.assertEqual(list(versions), [
            VersionInfo('1.0'),
        ])
github jimporter / mike / test / unit / test_versions.py View on Github external
def test_difference_update_nonexistent(self):
        versions = Versions()
        versions.add('1.0')
        versions.add('2.0')
        versions.add('3.0', aliases=['latest'])

        with self.assertRaises(KeyError):
            versions.difference_update(['1.0', 'latest', '4.0'])
        self.assertEqual(list(versions), [
            VersionInfo('3.0', aliases=['latest']),
            VersionInfo('2.0'),
            VersionInfo('1.0'),
        ])
github jimporter / mike / mike / commands.py View on Github external
def list_versions(branch='gh-pages'):
    try:
        return Versions.loads(git_utils.read_file(
            branch, versions_file, universal_newlines=True
        ))
    except git_utils.GitError:
        return Versions()
github jimporter / mike / mike / versions.py View on Github external
def loads(data):
        result = Versions()
        for i in json.loads(data):
            result.add(i['version'], i['title'], i['aliases'])
        return result