Files
@ ffd45b185016
Branch filter:
Location: kallithea/rhodecode/tests/vcs/base.py
ffd45b185016
3.7 KiB
text/x-python
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
This imports changes between changesets 21af6c4eab3d and 6177597791c2 in
RhodeCode's original repository, including only changes to Python files and HTML.
RhodeCode clearly licensed its changes to these files under GPLv3
in their /LICENSE file, which states the following:
The Python code and integrated HTML are licensed under the GPLv3 license.
(See:
https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE
or
http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE
for an online copy of that LICENSE file)
Conservancy reviewed these changes and confirmed that they can be licensed as
a whole to the Kallithea project under GPLv3-only.
While some of the contents committed herein are clearly licensed
GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the
statement above from RhodeCode indicates that they intend GPLv3-only as their
license, per GPLv3ยง14 and other relevant sections of GPLv3.
This imports changes between changesets 21af6c4eab3d and 6177597791c2 in
RhodeCode's original repository, including only changes to Python files and HTML.
RhodeCode clearly licensed its changes to these files under GPLv3
in their /LICENSE file, which states the following:
The Python code and integrated HTML are licensed under the GPLv3 license.
(See:
https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE
or
http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE
for an online copy of that LICENSE file)
Conservancy reviewed these changes and confirmed that they can be licensed as
a whole to the Kallithea project under GPLv3-only.
While some of the contents committed herein are clearly licensed
GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the
statement above from RhodeCode indicates that they intend GPLv3-only as their
license, per GPLv3ยง14 and other relevant sections of GPLv3.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | """
Module providing backend independent mixin class. It requires that
InMemoryChangeset class is working properly at backend class.
"""
import os
import time
import shutil
import datetime
from rhodecode.tests.vcs.conf import SCM_TESTS, get_new_dir
from rhodecode.lib import vcs
from rhodecode.lib.vcs.utils.compat import unittest
from rhodecode.lib.vcs.nodes import FileNode
class BackendTestMixin(object):
"""
This is a backend independent test case class which should be created
with ``type`` method.
It is required to set following attributes at subclass:
- ``backend_alias``: alias of used backend (see ``vcs.BACKENDS``)
- ``repo_path``: path to the repository which would be created for set of
tests
- ``recreate_repo_per_test``: If set to ``False``, repo would NOT be created
before every single test. Defaults to ``True``.
"""
recreate_repo_per_test = True
@classmethod
def get_backend(cls):
return vcs.get_backend(cls.backend_alias)
@classmethod
def _get_commits(cls):
commits = [
{
'message': u'Initial commit',
'author': u'Joe Doe <joe.doe@example.com>',
'date': datetime.datetime(2010, 1, 1, 20),
'added': [
FileNode('foobar', content='Foobar'),
FileNode('foobar2', content='Foobar II'),
FileNode('foo/bar/baz', content='baz here!'),
],
},
{
'message': u'Changes...',
'author': u'Jane Doe <jane.doe@example.com>',
'date': datetime.datetime(2010, 1, 1, 21),
'added': [
FileNode('some/new.txt', content='news...'),
],
'changed': [
FileNode('foobar', 'Foobar I'),
],
'removed': [],
},
]
return commits
@classmethod
def setUpClass(cls):
Backend = cls.get_backend()
cls.backend_class = Backend
cls.repo_path = get_new_dir(str(time.time()))
cls.repo = Backend(cls.repo_path, create=True)
cls.imc = cls.repo.in_memory_changeset
cls.default_branch = cls.repo.DEFAULT_BRANCH_NAME
for commit in cls._get_commits():
for node in commit.get('added', []):
cls.imc.add(FileNode(node.path, content=node.content))
for node in commit.get('changed', []):
cls.imc.change(FileNode(node.path, content=node.content))
for node in commit.get('removed', []):
cls.imc.remove(FileNode(node.path))
cls.tip = cls.imc.commit(message=unicode(commit['message']),
author=unicode(commit['author']),
date=commit['date'])
@classmethod
def tearDownClass(cls):
if not getattr(cls, 'recreate_repo_per_test', False) and \
'VCS_REMOVE_TEST_DIRS' in os.environ:
shutil.rmtree(cls.repo_path)
def setUp(self):
if getattr(self, 'recreate_repo_per_test', False):
self.__class__.setUpClass()
def tearDown(self):
if getattr(self, 'recreate_repo_per_test', False) and \
'VCS_REMOVE_TEST_DIRS' in os.environ:
shutil.rmtree(self.repo_path)
# For each backend create test case class
for alias in SCM_TESTS:
attrs = {
'backend_alias': alias,
}
cls_name = ''.join(('%s base backend test' % alias).title().split())
bases = (BackendTestMixin, unittest.TestCase)
globals()[cls_name] = type(cls_name, bases, attrs)
if __name__ == '__main__':
unittest.main()
|