##// END OF EJS Templates
dependencies: bumped test libraries.
marcink -
r3951:041016db default
parent child Browse files
Show More
@@ -0,0 +1,47 b''
1 import collections
2 # -*- coding: utf-8 -*-
3
4 # Copyright (C) 2010-2019 RhodeCode GmbH
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License, version 3
8 # (only), as published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU Affero General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #
18 # This program is dual-licensed. If you wish to learn more about the
19 # RhodeCode Enterprise Edition, including its added features, Support services,
20 # and proprietary license terms, please see https://rhodecode.com/licenses/
21
22 import pytest
23
24 from rhodecode.lib import audit_logger
25
26
27 @pytest.mark.parametrize('store_type', [
28 'store_web',
29 'store_api'
30 ])
31 @pytest.mark.parametrize('action, kwargs', [
32 ('repo.edit', {
33 'user': audit_logger.UserWrap(username='test-audit-log', ip_addr='8.8.8.8'),
34 'action_data': {'data': {'hello': 'world'}}
35 }),
36 ('repo.edit', {
37 'user': audit_logger.UserWrap(username=u'marcinkuΕΌmiΕ„', ip_addr='8.8.8.8'),
38 'action_data': {'data': {'hello': u'Δ…Δ™ΕΌΔ…βˆ‘Δ™Δ«Β¨Β¨Δ·Β©'}}
39 }),
40 ('repo.edit', {
41 'user': audit_logger.UserWrap(username='marcinkuΕΌmiΕ„', ip_addr='8.8.8.8'),
42 'action_data': {'data': {'hello': 'Δ…Δ™ΕΌΔ…βˆ‘Δ™Δ«Β¨Β¨Δ·Β©'}}
43 }),
44 ])
45 def test_store_audit_log(app, store_type, action, kwargs):
46 store_action = getattr(audit_logger, store_type)
47 store_action(action, **kwargs)
@@ -311,11 +311,11 b' self: super: {'
311 311 };
312 312 };
313 313 "coverage" = super.buildPythonPackage {
314 name = "coverage-4.5.3";
314 name = "coverage-4.5.4";
315 315 doCheck = false;
316 316 src = fetchurl {
317 url = "https://files.pythonhosted.org/packages/82/70/2280b5b29a0352519bb95ab0ef1ea942d40466ca71c53a2085bdeff7b0eb/coverage-4.5.3.tar.gz";
318 sha256 = "02f6m073qdispn96rc616hg0rnmw1pgqzw3bgxwiwza4zf9hirlx";
317 url = "https://files.pythonhosted.org/packages/85/d5/818d0e603685c4a613d56f065a721013e942088047ff1027a632948bdae6/coverage-4.5.4.tar.gz";
318 sha256 = "0p0j4di6h8k6ica7jwwj09azdcg4ycxq60i9qsskmsg94cd9yzg0";
319 319 };
320 320 meta = {
321 321 license = [ pkgs.lib.licenses.asl20 ];
@@ -961,14 +961,18 b' self: super: {'
961 961 };
962 962 };
963 963 "mock" = super.buildPythonPackage {
964 name = "mock-1.0.1";
964 name = "mock-3.0.5";
965 965 doCheck = false;
966 propagatedBuildInputs = [
967 self."six"
968 self."funcsigs"
969 ];
966 970 src = fetchurl {
967 url = "https://files.pythonhosted.org/packages/a2/52/7edcd94f0afb721a2d559a5b9aae8af4f8f2c79bc63fdbe8a8a6c9b23bbe/mock-1.0.1.tar.gz";
968 sha256 = "0kzlsbki6q0awf89rc287f3aj8x431lrajf160a70z0ikhnxsfdq";
971 url = "https://files.pythonhosted.org/packages/2e/ab/4fe657d78b270aa6a32f027849513b829b41b0f28d9d8d7f8c3d29ea559a/mock-3.0.5.tar.gz";
972 sha256 = "1hrp6j0yrx2xzylfv02qa8kph661m6yq4p0mc8fnimch9j4psrc3";
969 973 };
970 974 meta = {
971 license = [ pkgs.lib.licenses.bsdOriginal ];
975 license = [ pkgs.lib.licenses.bsdOriginal { fullName = "OSI Approved :: BSD License"; } ];
972 976 };
973 977 };
974 978 "more-itertools" = super.buildPythonPackage {
@@ -1253,11 +1257,11 b' self: super: {'
1253 1257 };
1254 1258 };
1255 1259 "py" = super.buildPythonPackage {
1256 name = "py-1.6.0";
1260 name = "py-1.8.0";
1257 1261 doCheck = false;
1258 1262 src = fetchurl {
1259 url = "https://files.pythonhosted.org/packages/4f/38/5f427d1eedae73063ce4da680d2bae72014995f9fdeaa57809df61c968cd/py-1.6.0.tar.gz";
1260 sha256 = "1wcs3zv9wl5m5x7p16avqj2gsrviyb23yvc3pr330isqs0sh98q6";
1263 url = "https://files.pythonhosted.org/packages/f1/5a/87ca5909f400a2de1561f1648883af74345fe96349f34f737cdfc94eba8c/py-1.8.0.tar.gz";
1264 sha256 = "0lsy1gajva083pzc7csj1cvbmminb7b4l6a0prdzyb3fd829nqyw";
1261 1265 };
1262 1266 meta = {
1263 1267 license = [ pkgs.lib.licenses.mit ];
@@ -1492,44 +1496,46 b' self: super: {'
1492 1496 };
1493 1497 };
1494 1498 "pytest" = super.buildPythonPackage {
1495 name = "pytest-3.8.2";
1499 name = "pytest-4.6.5";
1496 1500 doCheck = false;
1497 1501 propagatedBuildInputs = [
1498 1502 self."py"
1499 1503 self."six"
1500 self."setuptools"
1504 self."packaging"
1501 1505 self."attrs"
1502 self."more-itertools"
1503 1506 self."atomicwrites"
1504 1507 self."pluggy"
1508 self."importlib-metadata"
1509 self."wcwidth"
1505 1510 self."funcsigs"
1506 1511 self."pathlib2"
1512 self."more-itertools"
1507 1513 ];
1508 1514 src = fetchurl {
1509 url = "https://files.pythonhosted.org/packages/5f/d2/7f77f406ac505abda02ab4afb50d06ebf304f6ea42fca34f8f37529106b2/pytest-3.8.2.tar.gz";
1510 sha256 = "18nrwzn61kph2y6gxwfz9ms68rfvr9d4vcffsxng9p7jk9z18clk";
1515 url = "https://files.pythonhosted.org/packages/2a/c6/1d1f32f6a5009900521b12e6560fb6b7245b0d4bc3fb771acd63d10e30e1/pytest-4.6.5.tar.gz";
1516 sha256 = "0iykwwfp4h181nd7rsihh2120b0rkawlw7rvbl19sgfspncr3hwg";
1511 1517 };
1512 1518 meta = {
1513 1519 license = [ pkgs.lib.licenses.mit ];
1514 1520 };
1515 1521 };
1516 1522 "pytest-cov" = super.buildPythonPackage {
1517 name = "pytest-cov-2.6.0";
1523 name = "pytest-cov-2.7.1";
1518 1524 doCheck = false;
1519 1525 propagatedBuildInputs = [
1520 1526 self."pytest"
1521 1527 self."coverage"
1522 1528 ];
1523 1529 src = fetchurl {
1524 url = "https://files.pythonhosted.org/packages/d9/e2/58f90a316fbd94dd50bf5c826a23f3f5d079fb3cc448c1e9f0e3c33a3d2a/pytest-cov-2.6.0.tar.gz";
1525 sha256 = "0qnpp9y3ygx4jk4pf5ad71fh2skbvnr6gl54m7rg5qysnx4g0q73";
1530 url = "https://files.pythonhosted.org/packages/bb/0f/3db7ff86801883b21d5353b258c994b1b8e2abbc804e2273b8d0fd19004b/pytest-cov-2.7.1.tar.gz";
1531 sha256 = "0filvmmyqm715azsl09ql8hy2x7h286n6d8z5x42a1wpvvys83p0";
1526 1532 };
1527 1533 meta = {
1528 1534 license = [ pkgs.lib.licenses.bsdOriginal pkgs.lib.licenses.mit ];
1529 1535 };
1530 1536 };
1531 1537 "pytest-profiling" = super.buildPythonPackage {
1532 name = "pytest-profiling-1.3.0";
1538 name = "pytest-profiling-1.7.0";
1533 1539 doCheck = false;
1534 1540 propagatedBuildInputs = [
1535 1541 self."six"
@@ -1537,48 +1543,49 b' self: super: {'
1537 1543 self."gprof2dot"
1538 1544 ];
1539 1545 src = fetchurl {
1540 url = "https://files.pythonhosted.org/packages/f5/34/4626126e041a51ef50a80d0619519b18d20aef249aac25b0d0fdd47e57ee/pytest-profiling-1.3.0.tar.gz";
1541 sha256 = "08r5afx5z22yvpmsnl91l4amsy1yxn8qsmm61mhp06mz8zjs51kb";
1546 url = "https://files.pythonhosted.org/packages/39/70/22a4b33739f07f1732a63e33bbfbf68e0fa58cfba9d200e76d01921eddbf/pytest-profiling-1.7.0.tar.gz";
1547 sha256 = "0abz9gi26jpcfdzgsvwad91555lpgdc8kbymicmms8k2fqa8z4wk";
1542 1548 };
1543 1549 meta = {
1544 1550 license = [ pkgs.lib.licenses.mit ];
1545 1551 };
1546 1552 };
1547 1553 "pytest-runner" = super.buildPythonPackage {
1548 name = "pytest-runner-4.2";
1554 name = "pytest-runner-5.1";
1549 1555 doCheck = false;
1550 1556 src = fetchurl {
1551 url = "https://files.pythonhosted.org/packages/9e/b7/fe6e8f87f9a756fd06722216f1b6698ccba4d269eac6329d9f0c441d0f93/pytest-runner-4.2.tar.gz";
1552 sha256 = "1gkpyphawxz38ni1gdq1fmwyqcg02m7ypzqvv46z06crwdxi2gyj";
1557 url = "https://files.pythonhosted.org/packages/d9/6d/4b41a74b31720e25abd4799be72d54811da4b4d0233e38b75864dcc1f7ad/pytest-runner-5.1.tar.gz";
1558 sha256 = "0ykfcnpp8c22winj63qzc07l5axwlc9ikl8vn05sc32gv3417815";
1553 1559 };
1554 1560 meta = {
1555 1561 license = [ pkgs.lib.licenses.mit ];
1556 1562 };
1557 1563 };
1558 1564 "pytest-sugar" = super.buildPythonPackage {
1559 name = "pytest-sugar-0.9.1";
1565 name = "pytest-sugar-0.9.2";
1560 1566 doCheck = false;
1561 1567 propagatedBuildInputs = [
1562 1568 self."pytest"
1563 1569 self."termcolor"
1570 self."packaging"
1564 1571 ];
1565 1572 src = fetchurl {
1566 url = "https://files.pythonhosted.org/packages/3e/6a/a3f909083079d03bde11d06ab23088886bbe25f2c97fbe4bb865e2bf05bc/pytest-sugar-0.9.1.tar.gz";
1567 sha256 = "0b4av40dv30727m54v211r0nzwjp2ajkjgxix6j484qjmwpw935b";
1573 url = "https://files.pythonhosted.org/packages/55/59/f02f78d1c80f7e03e23177f60624c8106d4f23d124c921df103f65692464/pytest-sugar-0.9.2.tar.gz";
1574 sha256 = "1asq7yc4g8bx2sn7yy974mhc9ywvaihasjab4inkirdwn9s7mn7w";
1568 1575 };
1569 1576 meta = {
1570 1577 license = [ pkgs.lib.licenses.bsdOriginal ];
1571 1578 };
1572 1579 };
1573 1580 "pytest-timeout" = super.buildPythonPackage {
1574 name = "pytest-timeout-1.3.2";
1581 name = "pytest-timeout-1.3.3";
1575 1582 doCheck = false;
1576 1583 propagatedBuildInputs = [
1577 1584 self."pytest"
1578 1585 ];
1579 1586 src = fetchurl {
1580 url = "https://files.pythonhosted.org/packages/8c/3e/1b6a319d12ae7baa3acb7c18ff2c8630a09471a0319d43535c683b4d03eb/pytest-timeout-1.3.2.tar.gz";
1581 sha256 = "09wnmzvnls2mnsdz7x3c3sk2zdp6jl4dryvyj5i8hqz16q2zq5qi";
1587 url = "https://files.pythonhosted.org/packages/13/48/7a166eaa29c1dca6cc253e3ba5773ff2e4aa4f567c1ea3905808e95ac5c1/pytest-timeout-1.3.3.tar.gz";
1588 sha256 = "1cczcjhw4xx5sjkhxlhc5c1bkr7x6fcyx12wrnvwfckshdvblc2a";
1582 1589 };
1583 1590 meta = {
1584 1591 license = [ pkgs.lib.licenses.mit { fullName = "DFSG approved"; } ];
@@ -9,8 +9,11 b' vcsserver_config_http = rhodecode/tests/'
9 9
10 10 addopts =
11 11 --pdbcls=IPython.terminal.debugger:TerminalPdb
12 --strict-markers
12 13
13 14 markers =
14 15 vcs_operations: Mark tests depending on a running RhodeCode instance.
15 16 xfail_backends: Mark tests as xfail for given backends.
16 17 skip_backends: Mark tests as skipped for given backends.
18 backends: Mark backends
19 dbs: database markers for running tests for given DB
@@ -1,16 +1,16 b''
1 1 # test related requirements
2 pytest==3.8.2
3 py==1.6.0
4 pytest-cov==2.6.0
5 pytest-sugar==0.9.1
6 pytest-runner==4.2.0
7 pytest-profiling==1.3.0
8 pytest-timeout==1.3.2
2 pytest==4.6.5
3 py==1.8.0
4 pytest-cov==2.7.1
5 pytest-sugar==0.9.2
6 pytest-runner==5.1.0
7 pytest-profiling==1.7.0
8 pytest-timeout==1.3.3
9 9 gprof2dot==2017.9.19
10 10
11 mock==1.0.1
11 mock==3.0.5
12 12 cov-core==1.15.0
13 coverage==4.5.3
13 coverage==4.5.4
14 14
15 15 webtest==2.0.33
16 16 beautifulsoup4==4.6.3
@@ -31,36 +31,38 b' from rhodecode.api.tests.utils import ('
31 31 @pytest.fixture()
32 32 def make_repo_comments_factory(request):
33 33
34 def maker(repo):
35 user = User.get_first_super_admin()
36 commit = repo.scm_instance()[0]
34 class Make(object):
35
36 def make_comments(self, repo):
37 user = User.get_first_super_admin()
38 commit = repo.scm_instance()[0]
37 39
38 commit_id = commit.raw_id
39 file_0 = commit.affected_files[0]
40 comments = []
40 commit_id = commit.raw_id
41 file_0 = commit.affected_files[0]
42 comments = []
41 43
42 # general
43 CommentsModel().create(
44 text='General Comment', repo=repo, user=user, commit_id=commit_id,
45 comment_type=ChangesetComment.COMMENT_TYPE_NOTE, send_email=False)
44 # general
45 CommentsModel().create(
46 text='General Comment', repo=repo, user=user, commit_id=commit_id,
47 comment_type=ChangesetComment.COMMENT_TYPE_NOTE, send_email=False)
46 48
47 # inline
48 CommentsModel().create(
49 text='Inline Comment', repo=repo, user=user, commit_id=commit_id,
50 f_path=file_0, line_no='n1',
51 comment_type=ChangesetComment.COMMENT_TYPE_NOTE, send_email=False)
49 # inline
50 CommentsModel().create(
51 text='Inline Comment', repo=repo, user=user, commit_id=commit_id,
52 f_path=file_0, line_no='n1',
53 comment_type=ChangesetComment.COMMENT_TYPE_NOTE, send_email=False)
52 54
53 # todo
54 CommentsModel().create(
55 text='INLINE TODO Comment', repo=repo, user=user, commit_id=commit_id,
56 f_path=file_0, line_no='n1',
57 comment_type=ChangesetComment.COMMENT_TYPE_TODO, send_email=False)
55 # todo
56 CommentsModel().create(
57 text='INLINE TODO Comment', repo=repo, user=user, commit_id=commit_id,
58 f_path=file_0, line_no='n1',
59 comment_type=ChangesetComment.COMMENT_TYPE_TODO, send_email=False)
58 60
59 @request.addfinalizer
60 def cleanup():
61 for comment in comments:
62 Session().delete(comment)
63 return maker
61 @request.addfinalizer
62 def cleanup():
63 for comment in comments:
64 Session().delete(comment)
65 return Make()
64 66
65 67
66 68 @pytest.mark.usefixtures("testuser_api", "app")
@@ -76,7 +78,7 b' class TestGetRepo(object):'
76 78 make_repo_comments_factory, filters, expected_count):
77 79 commits = [{'message': 'A'}, {'message': 'B'}]
78 80 repo = backend.create_repo(commits=commits)
79 make_repo_comments_factory(repo)
81 make_repo_comments_factory.make_comments(repo)
80 82
81 83 api_call_params = {'repoid': repo.repo_name,}
82 84 api_call_params.update(filters)
@@ -92,12 +94,13 b' class TestGetRepo(object):'
92 94
93 95 assert len(result) == expected_count
94 96
95 def test_api_get_repo_comments_wrong_comment_typ(self, backend_hg):
97 def test_api_get_repo_comments_wrong_comment_type(
98 self, make_repo_comments_factory, backend_hg):
99 commits = [{'message': 'A'}, {'message': 'B'}]
100 repo = backend_hg.create_repo(commits=commits)
101 make_repo_comments_factory.make_comments(repo)
96 102
97 repo = backend_hg.create_repo()
98 make_repo_comments_factory(repo)
99
100 api_call_params = {'repoid': repo.repo_name,}
103 api_call_params = {'repoid': repo.repo_name}
101 104 api_call_params.update({'comment_type': 'bogus'})
102 105
103 106 expected = 'comment_type must be one of `{}` got {}'.format(
@@ -31,10 +31,11 b' from rhodecode.tests.fixture import Test'
31 31
32 32
33 33 def _get_dbs_from_metafunc(metafunc):
34 if hasattr(metafunc.function, 'dbs'):
35 # Supported backends by this test function, created from
36 # pytest.mark.dbs
37 backends = metafunc.definition.get_closest_marker('dbs').args
34 dbs_mark = metafunc.definition.get_closest_marker('dbs')
35
36 if dbs_mark:
37 # Supported backends by this test function, created from pytest.mark.dbs
38 backends = dbs_mark.args
38 39 else:
39 40 backends = metafunc.config.getoption('--dbs')
40 41 return backends
@@ -18,16 +18,11 b''
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 import os
22 import stat
23 import sys
24
25 21 import pytest
26 22 from mock import Mock, patch, DEFAULT
27 23
28 24 import rhodecode
29 25 from rhodecode.model import db, scm
30 from rhodecode.tests import no_newline_id_generator
31 26
32 27
33 28 def test_scm_instance_config(backend):
@@ -35,18 +30,17 b' def test_scm_instance_config(backend):'
35 30 with patch.multiple('rhodecode.model.db.Repository',
36 31 _get_instance=DEFAULT,
37 32 _get_instance_cached=DEFAULT) as mocks:
33
38 34 repo.scm_instance()
39 35 mocks['_get_instance'].assert_called_with(
40 36 config=None, cache=False)
41 37
42 config = {'some': 'value'}
43 repo.scm_instance(config=config)
38 repo.scm_instance(vcs_full_cache=False)
44 39 mocks['_get_instance'].assert_called_with(
45 config=config, cache=False)
40 config=None, cache=False)
46 41
47 with patch.dict(rhodecode.CONFIG, {'vcs_full_cache': 'true'}):
48 repo.scm_instance(config=config)
49 mocks['_get_instance_cached'].assert_called()
42 repo.scm_instance(vcs_full_cache=True)
43 mocks['_get_instance_cached'].assert_called()
50 44
51 45
52 46 def test_get_instance_config(backend):
@@ -30,7 +30,6 b' import subprocess32'
30 30 import time
31 31 import uuid
32 32 import dateutil.tz
33 import functools
34 33
35 34 import mock
36 35 import pyramid.testing
@@ -67,6 +66,7 b' from rhodecode.tests.utils import Custom'
67 66 from rhodecode.tests.fixture import Fixture
68 67 from rhodecode.config import utils as config_utils
69 68
69
70 70 def _split_comma(value):
71 71 return value.split(',')
72 72
@@ -120,14 +120,18 b' def pytest_collection_modifyitems(sessio'
120 120
121 121
122 122 def pytest_generate_tests(metafunc):
123
123 124 # Support test generation based on --backend parameter
124 125 if 'backend_alias' in metafunc.fixturenames:
125 126 backends = get_backends_from_metafunc(metafunc)
126 127 scope = None
127 128 if not backends:
128 129 pytest.skip("Not enabled for any of selected backends")
130
129 131 metafunc.parametrize('backend_alias', backends, scope=scope)
130 elif hasattr(metafunc.function, 'backends'):
132
133 backend_mark = metafunc.definition.get_closest_marker('backends')
134 if backend_mark:
131 135 backends = get_backends_from_metafunc(metafunc)
132 136 if not backends:
133 137 pytest.skip("Not enabled for any of selected backends")
@@ -135,10 +139,11 b' def pytest_generate_tests(metafunc):'
135 139
136 140 def get_backends_from_metafunc(metafunc):
137 141 requested_backends = set(metafunc.config.getoption('--backends'))
138 if hasattr(metafunc.function, 'backends'):
142 backend_mark = metafunc.definition.get_closest_marker('backends')
143 if backend_mark:
139 144 # Supported backends by this test function, created from
140 145 # pytest.mark.backends
141 backends = metafunc.definition.get_closest_marker('backends').args
146 backends = backend_mark.args
142 147 elif hasattr(metafunc.cls, 'backend_alias'):
143 148 # Support class attribute "backend_alias", this is mainly
144 149 # for legacy reasons for tests not yet using pytest.mark.backends
@@ -1810,17 +1815,3 b' def repo_groups(request):'
1810 1815 fixture.destroy_repo_group(parent_group)
1811 1816
1812 1817 return zombie_group, parent_group, child_group
1813
1814
1815 @pytest.fixture(scope="session")
1816 def tmp_path_factory(request):
1817 """Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session.
1818 """
1819
1820 class TempPathFactory:
1821
1822 def mktemp(self, basename):
1823 import tempfile
1824 return tempfile.mktemp(basename)
1825
1826 return TempPathFactory()
@@ -48,21 +48,21 b' class TestGitRepository(object):'
48 48 self.repo = GitRepository(TEST_GIT_REPO, bare=True)
49 49 self.repo.count()
50 50
51 def get_clone_repo(self, tmp_path_factory):
51 def get_clone_repo(self, tmpdir):
52 52 """
53 53 Return a non bare clone of the base repo.
54 54 """
55 clone_path = tmp_path_factory.mktemp('clone-url')
55 clone_path = str(tmpdir.join('clone-repo'))
56 56 repo_clone = GitRepository(
57 57 clone_path, create=True, src_url=self.repo.path, bare=False)
58 58
59 59 return repo_clone
60 60
61 def get_empty_repo(self, tmp_path_factory, bare=False):
61 def get_empty_repo(self, tmpdir, bare=False):
62 62 """
63 63 Return a non bare empty repo.
64 64 """
65 clone_path = tmp_path_factory.mktemp('empty-repo')
65 clone_path = str(tmpdir.join('empty-repo'))
66 66 return GitRepository(clone_path, create=True, bare=bare)
67 67
68 68 def test_wrong_repo_path(self):
@@ -72,7 +72,7 b' class TestGitRepository(object):'
72 72
73 73 def test_repo_clone(self, tmp_path_factory):
74 74 repo = GitRepository(TEST_GIT_REPO)
75 clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE
75 clone_path = '{}_{}'.format(tmp_path_factory.mktemp('_'), TEST_GIT_REPO_CLONE)
76 76 repo_clone = GitRepository(
77 77 clone_path,
78 78 src_url=TEST_GIT_REPO, create=True, do_workspace_checkout=True)
@@ -90,7 +90,7 b' class TestGitRepository(object):'
90 90
91 91 def test_repo_clone_with_update(self, tmp_path_factory):
92 92 repo = GitRepository(TEST_GIT_REPO)
93 clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE + '_update'
93 clone_path = '{}_{}_update'.format(tmp_path_factory.mktemp('_'), TEST_GIT_REPO_CLONE)
94 94
95 95 repo_clone = GitRepository(
96 96 clone_path,
@@ -103,7 +103,7 b' class TestGitRepository(object):'
103 103
104 104 def test_repo_clone_without_update(self, tmp_path_factory):
105 105 repo = GitRepository(TEST_GIT_REPO)
106 clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE + '_without_update'
106 clone_path = '{}_{}_without_update'.format(tmp_path_factory.mktemp('_'), TEST_GIT_REPO_CLONE)
107 107 repo_clone = GitRepository(
108 108 clone_path,
109 109 create=True, src_url=TEST_GIT_REPO, do_workspace_checkout=False)
@@ -116,7 +116,7 b' class TestGitRepository(object):'
116 116
117 117 def test_repo_clone_into_bare_repo(self, tmp_path_factory):
118 118 repo = GitRepository(TEST_GIT_REPO)
119 clone_path = tmp_path_factory.mktemp('_') + '_' + TEST_GIT_REPO_CLONE + '_bare.git'
119 clone_path = '{}_{}_bare.git'.format(tmp_path_factory.mktemp('_'), TEST_GIT_REPO_CLONE)
120 120 repo_clone = GitRepository(
121 121 clone_path, create=True, src_url=repo.path, bare=True)
122 122 assert repo_clone.bare
@@ -258,8 +258,8 b' TODO: To be written...'
258 258 def test_head(self):
259 259 assert self.repo.head == self.repo.get_commit().raw_id
260 260
261 def test_checkout_with_create(self, tmp_path_factory):
262 repo_clone = self.get_clone_repo(tmp_path_factory)
261 def test_checkout_with_create(self, tmpdir):
262 repo_clone = self.get_clone_repo(tmpdir)
263 263
264 264 new_branch = 'new_branch'
265 265 assert repo_clone._current_branch() == 'master'
@@ -271,22 +271,22 b' TODO: To be written...'
271 271 assert set(repo_clone.branches) == {'master', new_branch}
272 272 assert repo_clone._current_branch() == new_branch
273 273
274 def test_checkout(self, tmp_path_factory):
275 repo_clone = self.get_clone_repo(tmp_path_factory)
274 def test_checkout(self, tmpdir):
275 repo_clone = self.get_clone_repo(tmpdir)
276 276
277 277 repo_clone._checkout('new_branch', create=True)
278 278 repo_clone._checkout('master')
279 279
280 280 assert repo_clone._current_branch() == 'master'
281 281
282 def test_checkout_same_branch(self, tmp_path_factory):
283 repo_clone = self.get_clone_repo(tmp_path_factory)
282 def test_checkout_same_branch(self, tmpdir):
283 repo_clone = self.get_clone_repo(tmpdir)
284 284
285 285 repo_clone._checkout('master')
286 286 assert repo_clone._current_branch() == 'master'
287 287
288 def test_checkout_branch_already_exists(self, tmp_path_factory):
289 repo_clone = self.get_clone_repo(tmp_path_factory)
288 def test_checkout_branch_already_exists(self, tmpdir):
289 repo_clone = self.get_clone_repo(tmpdir)
290 290
291 291 with pytest.raises(RepositoryError):
292 292 repo_clone._checkout('master', create=True)
@@ -299,32 +299,32 b' TODO: To be written...'
299 299 with pytest.raises(RepositoryError):
300 300 self.repo._current_branch()
301 301
302 def test_current_branch_empty_repo(self, tmp_path_factory):
303 repo = self.get_empty_repo(tmp_path_factory)
302 def test_current_branch_empty_repo(self, tmpdir):
303 repo = self.get_empty_repo(tmpdir)
304 304 assert repo._current_branch() is None
305 305
306 306 def test_local_clone(self, tmp_path_factory):
307 clone_path = tmp_path_factory.mktemp('test-local-clone')
307 clone_path = str(tmp_path_factory.mktemp('test-local-clone'))
308 308 self.repo._local_clone(clone_path, 'master')
309 309 repo_clone = GitRepository(clone_path)
310 310
311 311 assert self.repo.commit_ids == repo_clone.commit_ids
312 312
313 def test_local_clone_with_specific_branch(self, tmp_path_factory):
314 source_repo = self.get_clone_repo(tmp_path_factory)
313 def test_local_clone_with_specific_branch(self, tmpdir):
314 source_repo = self.get_clone_repo(tmpdir)
315 315
316 316 # Create a new branch in source repo
317 317 new_branch_commit = source_repo.commit_ids[-3]
318 318 source_repo._checkout(new_branch_commit)
319 319 source_repo._checkout('new_branch', create=True)
320 320
321 clone_path = tmp_path_factory.mktemp('git-clone-path-1')
321 clone_path = str(tmpdir.join('git-clone-path-1'))
322 322 source_repo._local_clone(clone_path, 'new_branch')
323 323 repo_clone = GitRepository(clone_path)
324 324
325 325 assert source_repo.commit_ids[:-3 + 1] == repo_clone.commit_ids
326 326
327 clone_path = tmp_path_factory.mktemp('git-clone-path-2')
327 clone_path = str(tmpdir.join('git-clone-path-2'))
328 328 source_repo._local_clone(clone_path, 'master')
329 329 repo_clone = GitRepository(clone_path)
330 330
@@ -334,9 +334,9 b' TODO: To be written...'
334 334 with pytest.raises(RepositoryError):
335 335 self.repo._local_clone(self.repo.path, 'master')
336 336
337 def test_local_fetch(self, tmp_path_factory):
338 target_repo = self.get_empty_repo(tmp_path_factory)
339 source_repo = self.get_clone_repo(tmp_path_factory)
337 def test_local_fetch(self, tmpdir):
338 target_repo = self.get_empty_repo(tmpdir)
339 source_repo = self.get_clone_repo(tmpdir)
340 340
341 341 # Create a new branch in source repo
342 342 master_commit = source_repo.commit_ids[-1]
@@ -350,8 +350,8 b' TODO: To be written...'
350 350 target_repo._local_fetch(source_repo.path, 'master')
351 351 assert target_repo._last_fetch_heads() == [master_commit]
352 352
353 def test_local_fetch_from_bare_repo(self, tmp_path_factory):
354 target_repo = self.get_empty_repo(tmp_path_factory)
353 def test_local_fetch_from_bare_repo(self, tmpdir):
354 target_repo = self.get_empty_repo(tmpdir)
355 355 target_repo._local_fetch(self.repo.path, 'master')
356 356
357 357 master_commit = self.repo.commit_ids[-1]
@@ -361,15 +361,15 b' TODO: To be written...'
361 361 with pytest.raises(ValueError):
362 362 self.repo._local_fetch(self.repo.path, 'master')
363 363
364 def test_local_fetch_branch_does_not_exist(self, tmp_path_factory):
365 target_repo = self.get_empty_repo(tmp_path_factory)
364 def test_local_fetch_branch_does_not_exist(self, tmpdir):
365 target_repo = self.get_empty_repo(tmpdir)
366 366
367 367 with pytest.raises(RepositoryError):
368 368 target_repo._local_fetch(self.repo.path, 'new_branch')
369 369
370 def test_local_pull(self, tmp_path_factory):
371 target_repo = self.get_empty_repo(tmp_path_factory)
372 source_repo = self.get_clone_repo(tmp_path_factory)
370 def test_local_pull(self, tmpdir):
371 target_repo = self.get_empty_repo(tmpdir)
372 source_repo = self.get_clone_repo(tmpdir)
373 373
374 374 # Create a new branch in source repo
375 375 master_commit = source_repo.commit_ids[-1]
@@ -389,9 +389,9 b' TODO: To be written...'
389 389 with pytest.raises(RepositoryError):
390 390 self.repo._local_pull(self.repo.path, 'master')
391 391
392 def test_local_merge(self, tmp_path_factory):
393 target_repo = self.get_empty_repo(tmp_path_factory)
394 source_repo = self.get_clone_repo(tmp_path_factory)
392 def test_local_merge(self, tmpdir):
393 target_repo = self.get_empty_repo(tmpdir)
394 source_repo = self.get_clone_repo(tmpdir)
395 395
396 396 # Create a new branch in source repo
397 397 master_commit = source_repo.commit_ids[-1]
@@ -432,8 +432,8 b' TODO: To be written...'
432 432 assert not os.path.exists(
433 433 os.path.join(target_repo.path, '.git', 'MERGE_HEAD'))
434 434
435 def test_local_merge_into_empty_repo(self, tmp_path_factory):
436 target_repo = self.get_empty_repo(tmp_path_factory)
435 def test_local_merge_into_empty_repo(self, tmpdir):
436 target_repo = self.get_empty_repo(tmpdir)
437 437
438 438 # This is required as one cannot do a -ff-only merge in an empty repo.
439 439 target_repo._local_fetch(self.repo.path, 'master')
@@ -447,8 +447,8 b' TODO: To be written...'
447 447 self.repo._local_merge(
448 448 'merge_message', 'user name', 'user@name.com', None)
449 449
450 def test_local_push_non_bare(self, tmp_path_factory):
451 target_repo = self.get_empty_repo(tmp_path_factory)
450 def test_local_push_non_bare(self, tmpdir):
451 target_repo = self.get_empty_repo(tmpdir)
452 452
453 453 pushed_branch = 'pushed_branch'
454 454 self.repo._local_push('master', target_repo.path, pushed_branch)
@@ -462,8 +462,8 b' TODO: To be written...'
462 462 assert (target_repo.branches[pushed_branch] ==
463 463 self.repo.branches['master'])
464 464
465 def test_local_push_bare(self, tmp_path_factory):
466 target_repo = self.get_empty_repo(tmp_path_factory, bare=True)
465 def test_local_push_bare(self, tmpdir):
466 target_repo = self.get_empty_repo(tmpdir, bare=True)
467 467
468 468 pushed_branch = 'pushed_branch'
469 469 self.repo._local_push('master', target_repo.path, pushed_branch)
@@ -477,8 +477,8 b' TODO: To be written...'
477 477 assert (target_repo.branches[pushed_branch] ==
478 478 self.repo.branches['master'])
479 479
480 def test_local_push_non_bare_target_branch_is_checked_out(self, tmp_path_factory):
481 target_repo = self.get_clone_repo(tmp_path_factory)
480 def test_local_push_non_bare_target_branch_is_checked_out(self, tmpdir):
481 target_repo = self.get_clone_repo(tmpdir)
482 482
483 483 pushed_branch = 'pushed_branch'
484 484 # Create a new branch in source repo
@@ -498,8 +498,8 b' TODO: To be written...'
498 498 with pytest.raises(RepositoryError):
499 499 self.repo._local_push('master', target_repo.path, 'master')
500 500
501 def test_hooks_can_be_enabled_via_env_variable_for_local_push(self, tmp_path_factory):
502 target_repo = self.get_empty_repo(tmp_path_factory, bare=True)
501 def test_hooks_can_be_enabled_via_env_variable_for_local_push(self, tmpdir):
502 target_repo = self.get_empty_repo(tmpdir, bare=True)
503 503
504 504 with mock.patch.object(self.repo, 'run_git_command') as run_mock:
505 505 self.repo._local_push(
@@ -523,8 +523,8 b' TODO: To be written...'
523 523 f.write('\n'.join(script_lines))
524 524 os.chmod(hook_path, 0o755)
525 525
526 def test_local_push_does_not_execute_hook(self, tmp_path_factory):
527 target_repo = self.get_empty_repo(tmp_path_factory)
526 def test_local_push_does_not_execute_hook(self, tmpdir):
527 target_repo = self.get_empty_repo(tmpdir)
528 528
529 529 pushed_branch = 'pushed_branch'
530 530 self._add_failing_hook(target_repo.path, 'pre-receive')
@@ -539,8 +539,8 b' TODO: To be written...'
539 539 assert (target_repo.branches[pushed_branch] ==
540 540 self.repo.branches['master'])
541 541
542 def test_local_push_executes_hook(self, tmp_path_factory):
543 target_repo = self.get_empty_repo(tmp_path_factory, bare=True)
542 def test_local_push_executes_hook(self, tmpdir):
543 target_repo = self.get_empty_repo(tmpdir, bare=True)
544 544 self._add_failing_hook(target_repo.path, 'pre-receive', bare=True)
545 545 with pytest.raises(RepositoryError):
546 546 self.repo._local_push(
General Comments 0
You need to be logged in to leave comments. Login now