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