Show More
@@ -29,6 +29,7 b' import socket' | |||
|
29 | 29 | import subprocess32 |
|
30 | 30 | import time |
|
31 | 31 | import uuid |
|
32 | import dateutil.tz | |
|
32 | 33 | |
|
33 | 34 | import mock |
|
34 | 35 | import pyramid.testing |
@@ -1814,3 +1815,11 b' def root_repos_integration_stub(request,' | |||
|
1814 | 1815 | IntegrationModel().delete(integration) |
|
1815 | 1816 | |
|
1816 | 1817 | return integration |
|
1818 | ||
|
1819 | ||
|
1820 | @pytest.fixture | |
|
1821 | def local_dt_to_utc(): | |
|
1822 | def _factory(dt): | |
|
1823 | return dt.replace(tzinfo=dateutil.tz.tzlocal()).astimezone( | |
|
1824 | dateutil.tz.tzutc()).replace(tzinfo=None) | |
|
1825 | return _factory |
@@ -28,34 +28,6 b' from rhodecode.tests.vcs.base import Bac' | |||
|
28 | 28 | |
|
29 | 29 | class TestBranches(BackendTestMixin): |
|
30 | 30 | |
|
31 | @classmethod | |
|
32 | def _get_commits(cls): | |
|
33 | commits = [ | |
|
34 | { | |
|
35 | 'message': 'Initial commit', | |
|
36 | 'author': 'Joe Doe <joe.doe@example.com>', | |
|
37 | 'date': datetime.datetime(2010, 1, 1, 20), | |
|
38 | 'added': [ | |
|
39 | FileNode('foobar', content='Foobar'), | |
|
40 | FileNode('foobar2', content='Foobar II'), | |
|
41 | FileNode('foo/bar/baz', content='baz here!'), | |
|
42 | ], | |
|
43 | }, | |
|
44 | { | |
|
45 | 'message': 'Changes...', | |
|
46 | 'author': 'Jane Doe <jane.doe@example.com>', | |
|
47 | 'date': datetime.datetime(2010, 1, 1, 21), | |
|
48 | 'added': [ | |
|
49 | FileNode('some/new.txt', content='news...'), | |
|
50 | ], | |
|
51 | 'changed': [ | |
|
52 | FileNode('foobar', 'Foobar I'), | |
|
53 | ], | |
|
54 | 'removed': [], | |
|
55 | }, | |
|
56 | ] | |
|
57 | return commits | |
|
58 | ||
|
59 | 31 | def test_empty_repository_has_no_branches(self, vcsbackend): |
|
60 | 32 | empty_repo = vcsbackend.create_repo() |
|
61 | 33 | assert empty_repo.branches == {} |
@@ -71,9 +43,10 b' class TestBranches(BackendTestMixin):' | |||
|
71 | 43 | def test_closed_branches(self): |
|
72 | 44 | assert len(self.repo.branches_closed) == 0 |
|
73 | 45 | |
|
74 | def test_simple(self): | |
|
46 | def test_simple(self, local_dt_to_utc): | |
|
75 | 47 | tip = self.repo.get_commit() |
|
76 | assert tip.date == datetime.datetime(2010, 1, 1, 21) | |
|
48 | assert tip.message == 'Changes...' | |
|
49 | assert tip.date == local_dt_to_utc(datetime.datetime(2010, 1, 1, 21)) | |
|
77 | 50 | |
|
78 | 51 | @pytest.mark.backends("git", "hg") |
|
79 | 52 | def test_new_branch(self): |
@@ -145,7 +118,7 b' class TestBranches(BackendTestMixin):' | |||
|
145 | 118 | assert '123' in self.repo.branches |
|
146 | 119 | |
|
147 | 120 | |
|
148 | class TestSvnBranches: | |
|
121 | class TestSvnBranches(object): | |
|
149 | 122 | |
|
150 | 123 | def test_empty_repository_has_no_tags_and_branches(self, vcsbackend_svn): |
|
151 | 124 | empty_repo = vcsbackend_svn.create_repo() |
@@ -321,16 +321,13 b' class TestCommits(BackendTestMixin):' | |||
|
321 | 321 | def test_get_file_annotate(self): |
|
322 | 322 | file_added_commit = self.repo.get_commit(commit_idx=3) |
|
323 | 323 | annotations = list(file_added_commit.get_file_annotate('file_3.txt')) |
|
324 | ||
|
324 | 325 | line_no, commit_id, commit_loader, line = annotations[0] |
|
326 | ||
|
325 | 327 | assert line_no == 1 |
|
326 | 328 | assert commit_id == file_added_commit.raw_id |
|
327 | 329 | assert commit_loader() == file_added_commit |
|
328 | ||
|
329 | # git annotation is generated differently thus different results | |
|
330 | if self.repo.alias == 'git': | |
|
331 | assert line == '(Joe Doe 2010-01-03 08:00:00 +0000 1) Foobar 3' | |
|
332 | else: | |
|
333 | assert line == 'Foobar 3' | |
|
330 | assert 'Foobar 3' in line | |
|
334 | 331 | |
|
335 | 332 | def test_get_file_annotate_does_not_exist(self): |
|
336 | 333 | file_added_commit = self.repo.get_commit(commit_idx=2) |
@@ -519,7 +516,7 b' class TestCommitsChanges(BackendTestMixi' | |||
|
519 | 516 | }, |
|
520 | 517 | ] |
|
521 | 518 | |
|
522 | def test_initial_commit(self): | |
|
519 | def test_initial_commit(self, local_dt_to_utc): | |
|
523 | 520 | commit = self.repo.get_commit(commit_idx=0) |
|
524 | 521 | assert set(commit.added) == set([ |
|
525 | 522 | commit.get_node('foo/bar'), |
@@ -531,7 +528,8 b' class TestCommitsChanges(BackendTestMixi' | |||
|
531 | 528 | assert set(commit.removed) == set() |
|
532 | 529 | assert set(commit.affected_files) == set( |
|
533 | 530 | ['foo/bar', 'foo/bał', 'foobar', 'qwe']) |
|
534 |
assert commit.date == |
|
|
531 | assert commit.date == local_dt_to_utc( | |
|
532 | datetime.datetime(2010, 1, 1, 20, 0)) | |
|
535 | 533 | |
|
536 | 534 | def test_head_added(self): |
|
537 | 535 | commit = self.repo.get_commit() |
@@ -320,7 +320,7 b' class TestInMemoryCommit(BackendTestMixi' | |||
|
320 | 320 | repo = self.Backend(self.repo_path) |
|
321 | 321 | assert len(repo.commit_ids) == N |
|
322 | 322 | |
|
323 | def test_date_attr(self): | |
|
323 | def test_date_attr(self, local_dt_to_utc): | |
|
324 | 324 | node = FileNode('foobar.txt', content='Foobared!') |
|
325 | 325 | self.imc.add(node) |
|
326 | 326 | date = datetime.datetime(1985, 1, 30, 1, 45) |
@@ -328,7 +328,7 b' class TestInMemoryCommit(BackendTestMixi' | |||
|
328 | 328 | u"Committed at time when I was born ;-)", |
|
329 | 329 | author=u'lb', date=date) |
|
330 | 330 | |
|
331 | assert commit.date == date | |
|
331 | assert commit.date == local_dt_to_utc(date) | |
|
332 | 332 | |
|
333 | 333 | def assert_succesful_commit(self, added_nodes): |
|
334 | 334 | newtip = self.repo.get_commit() |
@@ -90,22 +90,24 b' class TestRepositoryBase(BackendTestMixi' | |||
|
90 | 90 | self.Backend.check_url(self.repo.path + "invalid", config) |
|
91 | 91 | |
|
92 | 92 | def test_get_contact(self): |
|
93 | self.repo.contact | |
|
93 | assert self.repo.contact | |
|
94 | 94 | |
|
95 | 95 | def test_get_description(self): |
|
96 | self.repo.description | |
|
96 | assert self.repo.description | |
|
97 | 97 | |
|
98 | 98 | def test_get_hook_location(self): |
|
99 | 99 | assert len(self.repo.get_hook_location()) != 0 |
|
100 | 100 | |
|
101 | def test_last_change(self): | |
|
102 |
assert self.repo.last_change >= |
|
|
101 | def test_last_change(self, local_dt_to_utc): | |
|
102 | assert self.repo.last_change >= local_dt_to_utc( | |
|
103 | datetime.datetime(2010, 1, 1, 21, 0)) | |
|
103 | 104 | |
|
104 | def test_last_change_in_empty_repository(self, vcsbackend): | |
|
105 | def test_last_change_in_empty_repository(self, vcsbackend, local_dt_to_utc): | |
|
105 | 106 | delta = datetime.timedelta(seconds=1) |
|
106 | start = datetime.datetime.now() | |
|
107 | ||
|
108 | start = local_dt_to_utc(datetime.datetime.now()) | |
|
107 | 109 | empty_repo = vcsbackend.create_repo() |
|
108 | now = datetime.datetime.now() | |
|
110 | now = local_dt_to_utc(datetime.datetime.now()) | |
|
109 | 111 | assert empty_repo.last_change >= start - delta |
|
110 | 112 | assert empty_repo.last_change <= now + delta |
|
111 | 113 |
General Comments 0
You need to be logged in to leave comments.
Login now