Files @ 55fc0bcce916
Branch filter:

Location: kallithea/kallithea/tests/vcs/test_getslice.py

Mads Kiilerich
setup: bump all upper pip dependency versions to minor updates of what currently is available and testable on pypi

Based on manual editing after:
pip freeze | sed -n 's/==/ /gp' | while read p v; do sed -i -e "/\<$p[ \"]/s/\(\",\|$\)/, < $v\1/gi" setup.py dev_requirements.txt; done

These updates have been tested with automated tests and some amount of manual
testing. Remaining problems will hopefully be caught by additional testing
before the branch is declared stable.
import datetime

from kallithea.lib.vcs.nodes import FileNode

from kallithea.tests.vcs.base import _BackendTestMixin


class GetsliceTestCaseMixin(_BackendTestMixin):

    @classmethod
    def _get_commits(cls):
        start_date = datetime.datetime(2010, 1, 1, 20)
        for x in xrange(5):
            yield {
                'message': 'Commit %d' % x,
                'author': 'Joe Doe <joe.doe@example.com>',
                'date': start_date + datetime.timedelta(hours=12 * x),
                'added': [
                    FileNode('file_%d.txt' % x, content='Foobar %d' % x),
                ],
            }

    def test__getslice__last_item_is_tip(self):
        assert list(self.repo[-1:])[0] == self.repo.get_changeset()

    def test__getslice__respects_start_index(self):
        assert list(self.repo[2:]) == [self.repo.get_changeset(rev) for rev in self.repo.revisions[2:]]

    def test__getslice__respects_negative_start_index(self):
        assert list(self.repo[-2:]) == [self.repo.get_changeset(rev) for rev in self.repo.revisions[-2:]]

    def test__getslice__respects_end_index(self):
        assert list(self.repo[:2]) == [self.repo.get_changeset(rev) for rev in self.repo.revisions[:2]]

    def test__getslice__respects_negative_end_index(self):
        assert list(self.repo[:-2]) == [self.repo.get_changeset(rev) for rev in self.repo.revisions[:-2]]


class TestGitGetslice(GetsliceTestCaseMixin):
    backend_alias = 'git'


class TestHgGetslice(GetsliceTestCaseMixin):
    backend_alias = 'hg'