示例#1
0
 def test_get_git_commit_id_general(self):
     """
     Tests the lenght of the git commit id.
     """
     git_commit_id = get_git_commit_id()
     if not git_commit_id == 'unknown':
         self.assertEqual(len(git_commit_id), 40)
示例#2
0
 def test_get_git_commit_id(self):
     """
     Tests the lenght of the git commit id.
     """
     git_commit_id = get_git_commit_id()
     if not git_commit_id == 'unknown':
         self.assertEqual(len(git_commit_id), 40)
示例#3
0
 def get_context_data(self, **kwargs):
     """
     Adds version strings to the context.
     """
     context = super().get_context_data(**kwargs)
     # OpenSlides version. During development the git commit id is added.
     if RELEASE:
         description = ''
     else:
         description = 'Commit %s' % get_git_commit_id()
     context['modules'] = [{
         'verbose_name': 'OpenSlides',
         'description': description,
         'version': get_openslides_version()
     }]
     # Versions of plugins.
     for plugin in settings.INSTALLED_PLUGINS:
         context['modules'].append({
             'verbose_name':
             get_plugin_verbose_name(plugin),
             'description':
             get_plugin_description(plugin),
             'version':
             get_plugin_version(plugin)
         })
     return context
示例#4
0
 def test_get_git_commit_id_general(self, mock):
     """
     Tests reading the content of a git reference (e.g. tags or branches).
     """
     mock.side_effect = (StringIO('ref: asdfgqwertfdfhiwer'), StringIO('TestOpenSlides-3.1415'))
     git_commit_id = get_git_commit_id()
     if not git_commit_id == 'unknown':
         self.assertEqual(git_commit_id, 'TestOpenSlides-3.1415')
示例#5
0
 def test_get_commit_id_without_ref(self, mock):
     """
     Tests reading the content of the git_commit_id file.
     """
     with tempfile.TemporaryFile() as git_file:
         git_file.write('test_id_ahyuGo7yefai7Nai')
         git_file.seek(0)
         mock.return_value = git_file
         self.assertEqual(get_git_commit_id(), 'test_id_ahyuGo7yefai7Nai')
示例#6
0
 def get_context_data(self, **kwargs):
     """
     Adds version strings to the context.
     """
     context = super(VersionView, self).get_context_data(**kwargs)
     # OpenSlides version. During development the git commit id is added.
     if RELEASE:
         description = ''
     else:
         description = 'Commit %s' % get_git_commit_id()
     context['modules'] = [{'verbose_name': 'OpenSlides',
                            'description': description,
                            'version': get_openslides_version()}]
     # Versions of plugins.
     for plugin in settings.INSTALLED_PLUGINS:
         context['modules'].append({'verbose_name': get_plugin_verbose_name(plugin),
                                    'description': get_plugin_description(plugin),
                                    'version': get_plugin_version(plugin)})
     return context
示例#7
0
    def get_context_data(self, **kwargs):
        """
        Adds version strings to the context.
        """
        context = super(VersionView, self).get_context_data(**kwargs)

        # OpenSlides version. During development the git commit id is added.
        openslides_version_string = get_version()
        if not RELEASE:
            openslides_version_string += ' – Commit %s' % get_git_commit_id()
        context['versions'] = [('OpenSlides', openslides_version_string)]

        # Versions of plugins.
        for plugin in settings.INSTALLED_PLUGINS:
            # Get plugin
            try:
                mod = import_module(plugin)
            except ImportError:
                continue

            # Get version.
            try:
                plugin_version = mod.get_version()
            except AttributeError:
                try:
                    plugin_version = mod.VERSION
                except AttributeError:
                    continue

            # Get name.
            try:
                plugin_name = mod.get_name()
            except AttributeError:
                try:
                    plugin_name = mod.NAME
                except AttributeError:
                    plugin_name = mod.__name__.split('.')[0]

            context['versions'].append((plugin_name, plugin_version))

        return context
示例#8
0
    def get_context_data(self, **kwargs):
        """
        Adds version strings to the context.
        """
        context = super(VersionView, self).get_context_data(**kwargs)

        # OpenSlides version. During development the git commit id is added.
        openslides_version_string = get_version()
        if not RELEASE:
            openslides_version_string += ' – Commit %s' % get_git_commit_id()
        context['versions'] = [('OpenSlides', openslides_version_string)]

        # Versions of plugins.
        for plugin in settings.INSTALLED_PLUGINS:
            # Get plugin
            try:
                mod = import_module(plugin)
            except ImportError:
                continue

            # Get version.
            try:
                plugin_version = mod.get_version()
            except AttributeError:
                try:
                    plugin_version = mod.VERSION
                except AttributeError:
                    continue

            # Get name.
            try:
                plugin_name = mod.get_name()
            except AttributeError:
                try:
                    plugin_name = mod.NAME
                except AttributeError:
                    plugin_name = mod.__name__.split('.')[0]

            context['versions'].append((plugin_name, plugin_version))

        return context
示例#9
0
    def get_context_data(self, **kwargs):
        context = super(VersionConfig, self).get_context_data(**kwargs)

        # OpenSlides version. During development the git commit id is added.
        openslides_version_string = get_version()
        if not RELEASE:
            openslides_version_string += ' Commit: %s' % get_git_commit_id()
        context['versions'] = [('OpenSlides', openslides_version_string)]

        # Version of plugins.
        for plugin in settings.INSTALLED_PLUGINS:
            try:
                mod = import_module(plugin)
                plugin_version = get_version(mod.VERSION)
            except (ImportError, AttributeError, AssertionError):
                continue
            try:
                plugin_name = mod.NAME
            except AttributeError:
                plugin_name = mod.__name__.split('.')[0]
            context['versions'].append((plugin_name, plugin_version))
        return context
示例#10
0
 def test_get_commit_id_without_ref(self, mock):
     """
     Tests reading the content of the git_commit_id file.
     """
     mock.return_value = StringIO('test_id_ahyuGo7yefai7Nai')
     self.assertEqual(get_git_commit_id(), 'test_id_ahyuGo7yefai7Nai')
示例#11
0
 def test_get_commit_id_unknown(self):
     """
     Tests unknown git commit id.
     """
     self.assertEqual(get_git_commit_id(), 'unknown')