##// END OF EJS Templates
tests: refactor test_update_repo for clarity
dan -
r70:1ecbb74d default
parent child Browse files
Show More
@@ -37,27 +37,24 b' class SAME_AS_UPDATES(object): """ Const'
37 37 @pytest.mark.usefixtures("testuser_api", "app")
38 38 class TestApiUpdateRepo(object):
39 39
40 @pytest.mark.parametrize("changing_attr, updates, expected", [
41 ('owner', {'owner': TEST_USER_REGULAR_LOGIN}, SAME_AS_UPDATES),
42 ('description', {'description': 'new description'}, SAME_AS_UPDATES),
43 ('clone_uri', {'clone_uri': 'http://foo.com/repo'}, SAME_AS_UPDATES),
44 ('clone_uri', {'clone_uri': None}, {'clone_uri': ''}),
45 ('clone_uri', {'clone_uri': ''}, {'clone_uri': ''}),
46 ('landing_rev', {'landing_rev': 'branch:master'},
47 {'landing_rev': ['branch', 'master']}),
48 ('enable_statistics', {'enable_statistics': True}, SAME_AS_UPDATES),
49 ('enable_locking', {'enable_locking': True}, SAME_AS_UPDATES),
50 ('enable_downloads', {'enable_downloads': True}, SAME_AS_UPDATES),
51 ('name', {'name': 'new_repo_name'},
52 {'repo_name': 'new_repo_name'}),
53 ('repo_group',
54 {'group': 'test_group_for_update'},
40 @pytest.mark.parametrize("updates, expected", [
41 ({'owner': TEST_USER_REGULAR_LOGIN}, SAME_AS_UPDATES),
42 ({'description': 'new description'}, SAME_AS_UPDATES),
43 ({'clone_uri': 'http://foo.com/repo'}, SAME_AS_UPDATES),
44 ({'clone_uri': None}, {'clone_uri': ''}),
45 ({'clone_uri': ''}, {'clone_uri': ''}),
46 ({'landing_rev': 'branch:master'}, {'landing_rev': ['branch','master']}),
47 ({'enable_statistics': True}, SAME_AS_UPDATES),
48 ({'enable_locking': True}, SAME_AS_UPDATES),
49 ({'enable_downloads': True}, SAME_AS_UPDATES),
50 ({'name': 'new_repo_name'}, {'repo_name': 'new_repo_name'}),
51 ({'group': 'test_group_for_update'},
55 52 {'repo_name': 'test_group_for_update/%s' % UPDATE_REPO_NAME}),
56 53 ])
57 def test_api_update_repo(self, changing_attr, updates, expected, backend):
54 def test_api_update_repo(self, updates, expected, backend):
58 55 repo_name = UPDATE_REPO_NAME
59 56 repo = fixture.create_repo(repo_name, repo_type=backend.alias)
60 if changing_attr == 'repo_group':
57 if updates.get('group'):
61 58 fixture.create_repo_group(updates['group'])
62 59
63 60 expected_api_data = repo.get_api_data(include_secrets=True)
@@ -71,9 +68,9 b' class TestApiUpdateRepo(object):'
71 68 self.apikey, 'update_repo', repoid=repo_name, **updates)
72 69 response = api_call(self.app, params)
73 70
74 if changing_attr == 'name':
71 if updates.get('name'):
75 72 repo_name = updates['name']
76 if changing_attr == 'repo_group':
73 if updates.get('group'):
77 74 repo_name = '/'.join([updates['group'], repo_name])
78 75
79 76 try:
@@ -84,7 +81,7 b' class TestApiUpdateRepo(object):'
84 81 assert_ok(id_, expected, given=response.body)
85 82 finally:
86 83 fixture.destroy_repo(repo_name)
87 if changing_attr == 'repo_group':
84 if updates.get('group'):
88 85 fixture.destroy_repo_group(updates['group'])
89 86
90 87 def test_api_update_repo_fork_of_field(self, backend):
General Comments 0
You need to be logged in to leave comments. Login now