Show More
@@ -21,19 +21,19 b' import os' | |||||
21 |
|
21 | |||
22 | import mock |
|
22 | import mock | |
23 | import pytest |
|
23 | import pytest | |
|
24 | from collections import OrderedDict | |||
24 |
|
25 | |||
25 | from rhodecode.apps.repository.tests.test_repo_compare import ComparePage |
|
26 | from rhodecode.apps.repository.tests.test_repo_compare import ComparePage | |
26 | from rhodecode.apps.repository.views.repo_files import RepoFilesView, get_archive_name, get_path_sha |
|
27 | from rhodecode.apps.repository.views.repo_files import RepoFilesView, get_archive_name, get_path_sha | |
27 | from rhodecode.lib import helpers as h |
|
28 | from rhodecode.lib import helpers as h | |
28 | from collections import OrderedDict |
|
|||
29 | from rhodecode.lib.ext_json import json |
|
29 | from rhodecode.lib.ext_json import json | |
30 | from rhodecode.lib.str_utils import safe_str |
|
30 | from rhodecode.lib.str_utils import safe_str | |
31 | from rhodecode.lib.vcs import nodes |
|
31 | from rhodecode.lib.vcs import nodes | |
|
32 | from rhodecode.lib.vcs.conf import settings | |||
|
33 | from rhodecode.model.db import Session, Repository | |||
32 |
|
34 | |||
33 | from rhodecode.lib.vcs.conf import settings |
|
|||
34 | from rhodecode.tests import assert_session_flash |
|
35 | from rhodecode.tests import assert_session_flash | |
35 | from rhodecode.tests.fixture import Fixture |
|
36 | from rhodecode.tests.fixture import Fixture | |
36 | from rhodecode.model.db import Session |
|
|||
37 |
|
37 | |||
38 | fixture = Fixture() |
|
38 | fixture = Fixture() | |
39 |
|
39 | |||
@@ -171,7 +171,7 b' class TestFilesViews(object):' | |||||
171 | {'message': 'b', 'branch': new_branch} |
|
171 | {'message': 'b', 'branch': new_branch} | |
172 | ] |
|
172 | ] | |
173 | backend.create_repo(commits) |
|
173 | backend.create_repo(commits) | |
174 |
backend.repo.landing_rev = "branch: |
|
174 | backend.repo.landing_rev = f"branch:{new_branch}" | |
175 | Session().commit() |
|
175 | Session().commit() | |
176 |
|
176 | |||
177 | # get response based on tip and not new commit |
|
177 | # get response based on tip and not new commit | |
@@ -187,8 +187,7 b' class TestFilesViews(object):' | |||||
187 | commit_id=landing_rev, params={'at': landing_rev}) |
|
187 | commit_id=landing_rev, params={'at': landing_rev}) | |
188 |
|
188 | |||
189 | assert landing_rev != 'tip' |
|
189 | assert landing_rev != 'tip' | |
190 | response.mustcontain( |
|
190 | response.mustcontain(f'<li class="active"><a class="menulink" href="{files_url}">') | |
191 | '<li class="active"><a class="menulink" href="%s">' % files_url) |
|
|||
192 |
|
191 | |||
193 | def test_show_files_commit(self, backend): |
|
192 | def test_show_files_commit(self, backend): | |
194 | commit = backend.repo.get_commit(commit_idx=32) |
|
193 | commit = backend.repo.get_commit(commit_idx=32) | |
@@ -526,9 +525,10 b' class TestRepositoryArchival(object):' | |||||
526 | def test_archival(self, backend): |
|
525 | def test_archival(self, backend): | |
527 | backend.enable_downloads() |
|
526 | backend.enable_downloads() | |
528 | commit = backend.repo.get_commit(commit_idx=173) |
|
527 | commit = backend.repo.get_commit(commit_idx=173) | |
|
528 | ||||
529 | for a_type, content_type, extension in settings.ARCHIVE_SPECS: |
|
529 | for a_type, content_type, extension in settings.ARCHIVE_SPECS: | |
530 | path_sha = get_path_sha('/') |
|
530 | path_sha = get_path_sha('/') | |
531 | filename = get_archive_name(backend.repo_name, commit_sha=commit.short_id, ext=extension, path_sha=path_sha) |
|
531 | filename = get_archive_name(backend.repo_id, backend.repo_name, commit_sha=commit.short_id, ext=extension, path_sha=path_sha) | |
532 |
|
532 | |||
533 | fname = commit.raw_id + extension |
|
533 | fname = commit.raw_id + extension | |
534 | response = self.app.get( |
|
534 | response = self.app.get( | |
@@ -538,19 +538,19 b' class TestRepositoryArchival(object):' | |||||
538 |
|
538 | |||
539 | assert response.status == '200 OK' |
|
539 | assert response.status == '200 OK' | |
540 | headers = [ |
|
540 | headers = [ | |
541 |
('Content-Disposition', 'attachment; filename= |
|
541 | ('Content-Disposition', f'attachment; filename={filename}'), | |
542 |
('Content-Type', |
|
542 | ('Content-Type', content_type), | |
543 | ] |
|
543 | ] | |
544 |
|
544 | |||
545 | for header in headers: |
|
545 | for header in headers: | |
546 | assert header in response.headers.items() |
|
546 | assert header in list(response.headers.items()) | |
547 |
|
547 | |||
548 | def test_archival_no_hash(self, backend): |
|
548 | def test_archival_no_hash(self, backend): | |
549 | backend.enable_downloads() |
|
549 | backend.enable_downloads() | |
550 | commit = backend.repo.get_commit(commit_idx=173) |
|
550 | commit = backend.repo.get_commit(commit_idx=173) | |
551 | for a_type, content_type, extension in settings.ARCHIVE_SPECS: |
|
551 | for a_type, content_type, extension in settings.ARCHIVE_SPECS: | |
552 | path_sha = get_path_sha('/') |
|
552 | path_sha = get_path_sha('/') | |
553 | filename = get_archive_name(backend.repo_name, commit_sha=commit.short_id, ext=extension, path_sha=path_sha, with_hash=False) |
|
553 | filename = get_archive_name(backend.repo_id, backend.repo_name, commit_sha=commit.short_id, ext=extension, path_sha=path_sha, with_hash=False) | |
554 |
|
554 | |||
555 | fname = commit.raw_id + extension |
|
555 | fname = commit.raw_id + extension | |
556 | response = self.app.get( |
|
556 | response = self.app.get( | |
@@ -560,8 +560,8 b' class TestRepositoryArchival(object):' | |||||
560 |
|
560 | |||
561 | assert response.status == '200 OK' |
|
561 | assert response.status == '200 OK' | |
562 | headers = [ |
|
562 | headers = [ | |
563 |
('Content-Disposition', 'attachment; filename= |
|
563 | ('Content-Disposition', f'attachment; filename={filename}'), | |
564 |
('Content-Type', |
|
564 | ('Content-Type', content_type), | |
565 | ] |
|
565 | ] | |
566 |
|
566 | |||
567 | for header in headers: |
|
567 | for header in headers: | |
@@ -574,7 +574,7 b' class TestRepositoryArchival(object):' | |||||
574 |
|
574 | |||
575 | for a_type, content_type, extension in settings.ARCHIVE_SPECS: |
|
575 | for a_type, content_type, extension in settings.ARCHIVE_SPECS: | |
576 | path_sha = get_path_sha(at_path) |
|
576 | path_sha = get_path_sha(at_path) | |
577 | filename = get_archive_name(backend.repo_name, commit_sha=commit.short_id, ext=extension, path_sha=path_sha) |
|
577 | filename = get_archive_name(backend.repo_id, backend.repo_name, commit_sha=commit.short_id, ext=extension, path_sha=path_sha) | |
578 |
|
578 | |||
579 | fname = commit.raw_id + extension |
|
579 | fname = commit.raw_id + extension | |
580 | response = self.app.get( |
|
580 | response = self.app.get( | |
@@ -584,8 +584,8 b' class TestRepositoryArchival(object):' | |||||
584 |
|
584 | |||
585 | assert response.status == '200 OK' |
|
585 | assert response.status == '200 OK' | |
586 | headers = [ |
|
586 | headers = [ | |
587 |
('Content-Disposition', 'attachment; filename= |
|
587 | ('Content-Disposition', f'attachment; filename={filename}'), | |
588 |
('Content-Type', |
|
588 | ('Content-Type', content_type), | |
589 | ] |
|
589 | ] | |
590 |
|
590 | |||
591 | for header in headers: |
|
591 | for header in headers: | |
@@ -610,7 +610,7 b' class TestRepositoryArchival(object):' | |||||
610 | '00x000000', 'tar', 'wrong', '@$@$42413232', '232dffcd']) |
|
610 | '00x000000', 'tar', 'wrong', '@$@$42413232', '232dffcd']) | |
611 | def test_archival_wrong_commit_id(self, backend, commit_id): |
|
611 | def test_archival_wrong_commit_id(self, backend, commit_id): | |
612 | backend.enable_downloads() |
|
612 | backend.enable_downloads() | |
613 |
fname = ' |
|
613 | fname = f'{commit_id}.zip' | |
614 |
|
614 | |||
615 | response = self.app.get( |
|
615 | response = self.app.get( | |
616 | route_path('repo_archivefile', |
|
616 | route_path('repo_archivefile', |
@@ -125,7 +125,7 b' def get_matching_phrase_offsets(text, ph' | |||||
125 |
|
125 | |||
126 |
|
126 | |||
127 | def get_matching_markers_offsets(text, markers=None): |
|
127 | def get_matching_markers_offsets(text, markers=None): | |
128 | """ |
|
128 | r""" | |
129 | Returns a list of string offsets in `text` that the are between matching markers |
|
129 | Returns a list of string offsets in `text` that the are between matching markers | |
130 |
|
130 | |||
131 | >>> get_matching_markers_offsets('$1some$2 text $1here$2 marked', ['\$1(.*?)\$2']) |
|
131 | >>> get_matching_markers_offsets('$1some$2 text $1here$2 marked', ['\$1(.*?)\$2']) |
@@ -489,6 +489,11 b' class Backend(object):' | |||||
489 | return self._test_repo_container(key, self.alias, config) |
|
489 | return self._test_repo_container(key, self.alias, config) | |
490 |
|
490 | |||
491 | @property |
|
491 | @property | |
|
492 | def repo_id(self): | |||
|
493 | # just fake some repo_id | |||
|
494 | return self.repo.repo_id | |||
|
495 | ||||
|
496 | @property | |||
492 | def repo(self): |
|
497 | def repo(self): | |
493 | """ |
|
498 | """ | |
494 | Returns the "current" repository. This is the vcs_test repo or the |
|
499 | Returns the "current" repository. This is the vcs_test repo or the |
General Comments 0
You need to be logged in to leave comments.
Login now