本文整理汇总了Python中tests.create_projects_git函数的典型用法代码示例。如果您正苦于以下问题:Python create_projects_git函数的具体用法?Python create_projects_git怎么用?Python create_projects_git使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_projects_git函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureExcludeGroupIndex, self).setUp()
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
# Create a ``provenpackger`` group:
msg = pagure.lib.query.add_group(
self.session,
group_name="provenpackager",
display_name="Proven Packagers",
description="Packagers having access to all the repo",
group_type="user",
user="pingou",
is_admin=False,
blacklist=[],
)
self.session.commit()
self.assertEqual(
msg, "User `pingou` added to the group `provenpackager`."
)
# Add the `provenpackager` group to the test2 project
project = pagure.lib.query._get_project(self.session, "test2")
msg = pagure.lib.query.add_group_to_project(
session=self.session,
project=project,
new_group="provenpackager",
user="pingou",
)
self.session.commit()
self.assertEqual(msg, "Group added")
开发者ID:pypingou,项目名称:pagure,代码行数:33,代码来源:test_pagure_exclude_group_index.py
示例2: test_milestones_without_dates
def test_milestones_without_dates(self, p_send_email, p_ugt):
""" Test creating two milestones with no dates. """
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(tests.HERE), bare=True)
user = tests.FakeUser()
user.username = 'pingou'
with tests.user_set(pagure.APP, user):
# Get the CSRF token
output = self.app.get('/test/settings')
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'milestones': ['v1.0', 'v2.0'],
'milestone_dates': ['', ''],
'csrf_token': csrf_token,
}
output = self.app.post(
'/test/update/milestones', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
# Check the redirect
self.assertIn(
u'<title>Settings - test - Pagure</title>', output.data)
self.assertIn(u'<h3>Settings for test</h3>', output.data)
self.assertIn(u'Milestones updated', output.data)
# Check the result of the action -- Milestones recorded
repo = pagure.lib.get_project(self.session, 'test')
self.assertEqual(repo.milestones, {u'v1.0': u'', u'v2.0': u''})
开发者ID:0-T-0,项目名称:pagure,代码行数:29,代码来源:test_pagure_flask_ui_roadmap.py
示例3: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureFlaskApiProjectBlockuserTests, self).setUp()
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
tests.create_tokens(self.session)
tests.create_tokens_acl(self.session)
item = pagure.lib.model.Token(
id="aaabbbcccdddeee",
user_id=2,
project_id=1,
expiration=datetime.datetime.utcnow()
+ datetime.timedelta(days=30),
)
self.session.add(item)
self.session.commit()
tests.create_tokens_acl(self.session, token_id="aaabbbcccdddeee")
project = pagure.lib.query.get_authorized_project(self.session, "test")
self.assertEqual(project.block_users, [])
self.blocked_users = []
project = pagure.lib.query.get_authorized_project(
self.session, "test2"
)
project.block_users = ["foo"]
self.session.add(project)
self.session.commit()
开发者ID:pypingou,项目名称:pagure,代码行数:30,代码来源:test_pagure_flask_api_project_blockuser.py
示例4: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureFlaskApiProjectUpdateWatchTests, self).setUp()
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "tickets"))
tests.create_tokens(self.session)
tests.create_tokens_acl(self.session)
# Create normal issue
repo = pagure.lib.query.get_authorized_project(self.session, "test")
msg = pagure.lib.query.new_issue(
session=self.session,
repo=repo,
title="Test issue #1",
content="We should work on this",
user="pingou",
private=False,
)
self.session.commit()
self.assertEqual(msg.title, "Test issue #1")
# Create project-less token for user foo
item = pagure.lib.model.Token(
id="project-less-foo",
user_id=1,
project_id=None,
expiration=datetime.datetime.utcnow()
+ datetime.timedelta(days=30),
)
self.session.add(item)
self.session.commit()
tests.create_tokens_acl(self.session, token_id="project-less-foo")
开发者ID:pypingou,项目名称:pagure,代码行数:33,代码来源:test_pagure_flask_api_project_update_watch.py
示例5: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureFlaskPluginPagureHooktests, self).setUp()
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"))
tests.create_projects_git(os.path.join(self.path, "repos", "docs"))
开发者ID:pypingou,项目名称:pagure,代码行数:7,代码来源:test_pagure_flask_ui_plugins_pagure_hook.py
示例6: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureFlaskApiIssueCreatetests, self).setUp()
pagure.config.config["TICKETS_FOLDER"] = None
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "tickets"))
tests.create_tokens(self.session)
tests.create_tokens_acl(self.session)
# Create project-less token for user foo
item = pagure.lib.model.Token(
id="project-less-foo",
user_id=2,
project_id=None,
expiration=datetime.datetime.utcnow()
+ datetime.timedelta(days=30),
)
self.session.add(item)
self.session.commit()
tests.create_tokens_acl(self.session, token_id="project-less-foo")
# Create project-specific token for user foo
item = pagure.lib.model.Token(
id="project-specific-foo",
user_id=2,
project_id=1,
expiration=datetime.datetime.utcnow()
+ datetime.timedelta(days=30),
)
self.session.add(item)
self.session.commit()
tests.create_tokens_acl(self.session, token_id="project-specific-foo")
开发者ID:pypingou,项目名称:pagure,代码行数:34,代码来源:test_pagure_flask_api_issue_create.py
示例7: test_view_plugin_page
def test_view_plugin_page(self):
""" Test the view_plugin_page endpoint. """
output = self.app.get('/foo/settings/Mail')
self.assertEqual(output.status_code, 302)
user = tests.FakeUser()
with tests.user_set(pagure.APP, user):
output = self.app.get('/foo/settings/Mail')
self.assertEqual(output.status_code, 404)
tests.create_projects(self.session)
tests.create_projects_git(tests.HERE)
output = self.app.get('/test/settings/Mail')
self.assertEqual(output.status_code, 403)
user.username = 'pingou'
with tests.user_set(pagure.APP, user):
output = self.app.get('/test/settings/Mail')
self.assertEqual(output.status_code, 200)
self.assertIn(
'<form action="/test/settings/Mail" method="post">',
output.data)
self.assertIn(
'<td><label for="mail_to">Mail to</label></td>',
output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'active': True,
'mail_to': '[email protected]',
'csrf_token': csrf_token,
}
output = self.app.post(
'/test/settings/Mail', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertIn(
'<section class="settings">\n <h3>Settings for test</h3>',
output.data)
self.assertIn(
'</button>\n Hook Mail activated', output.data)
data = {
'mail_to': '',
'csrf_token': csrf_token,
}
output = self.app.post(
'/test/settings/Mail', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertIn(
'<section class="settings">\n <h3>Settings for test</h3>',
output.data)
self.assertIn(
'</button>\n Hook Mail inactived', output.data)
开发者ID:denys-duchier,项目名称:pagure,代码行数:59,代码来源:test_pagure_flask_ui_plugins.py
示例8: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureGetRemoteRepoPath, self).setUp()
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
tests.add_content_git_repo(
os.path.join(self.path, "repos", "test2.git")
)
开发者ID:pypingou,项目名称:pagure,代码行数:9,代码来源:test_pagure_flask.py
示例9: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureFlaskQuickReplytest, self).setUp()
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
self.admin = tests.FakeUser(username="pingou")
self.user = tests.FakeUser(username="ralph")
self.repo = pagure.lib.query._get_project(self.session, "test")
开发者ID:pypingou,项目名称:pagure,代码行数:10,代码来源:test_pagure_flask_ui_quick_reply.py
示例10: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureFlaskPluginPagureNoNewBranchHooktests, self).setUp()
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"))
pagure.config.config["GIT_FOLDER"] = os.path.join(self.path, "repos")
with tests.user_set(self.app.application, tests.FakeUser()):
self.csrf_token = self.get_csrf()
开发者ID:pypingou,项目名称:pagure,代码行数:11,代码来源:test_pagure_flask_ui_plugins_pagure_no_new_branch.py
示例11: test_mirror_project
def test_mirror_project(self, rgl):
""" Test the mirror_project method. """
rgl.return_value = ("stdout", "stderr")
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
# before
self.assertEqual(
sorted(os.listdir(self.sshkeydir)), ["test", "test.pub"]
)
project = pagure.lib.query.get_authorized_project(self.session, "test")
self.assertIsNotNone(project.mirror_hook.public_key)
self.assertTrue(project.mirror_hook.public_key.startswith("ssh-rsa "))
pagure.lib.tasks_mirror.mirror_project(
username=None, namespace=None, name="test"
)
# after
self.assertEqual(
sorted(os.listdir(self.sshkeydir)), ["test", "test.pub"]
)
project = pagure.lib.query.get_authorized_project(self.session, "test")
self.assertIsNotNone(project.mirror_hook.public_key)
self.assertTrue(project.mirror_hook.public_key.startswith("ssh-rsa "))
ssh_script = os.path.abspath(
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"..",
"pagure",
"lib",
"ssh_script.sh",
)
)
calls = [
call(
[
"push",
"--mirror",
"ssh://[email protected]/foobar.git",
],
abspath=os.path.join(self.path, "repos", "test.git"),
env={
"GIT_SSH": ssh_script,
"SSHKEY": "%s/sshkeys/test" % self.path,
},
error=True,
)
]
self.assertEqual(rgl.call_count, 1)
self.assertEqual(calls, rgl.mock_calls)
开发者ID:pypingou,项目名称:pagure,代码行数:53,代码来源:test_pagure_lib_task_mirror.py
示例12: test_view_commit_old_with_bogus_url
def test_view_commit_old_with_bogus_url(self):
""" Test the view_commit_old endpoint. """
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
# Add a README to the git repo - First commit
tests.add_readme_git_repo(os.path.join(self.path, "repos", "test.git"))
pygit2.Repository(os.path.join(self.path, "repos", "test.git"))
# View first commit
output = self.app.get("/apple-touch-icon-152x152-precomposed.png")
self.assertEqual(output.status_code, 404)
开发者ID:pypingou,项目名称:pagure,代码行数:13,代码来源:test_pagure_flask_ui_old_commit.py
示例13: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureFlaskGiveRepotests, self).setUp()
pagure.config.config["VIRUS_SCAN_ATTACHMENTS"] = False
pagure.config.config["UPLOAD_FOLDER_URL"] = "/releases/"
pagure.config.config["UPLOAD_FOLDER_PATH"] = os.path.join(
self.path, "releases"
)
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
self._check_user(user="pingou")
开发者ID:pypingou,项目名称:pagure,代码行数:13,代码来源:test_pagure_flask_ui_app_give_project.py
示例14: test_milestones_without_dates
def test_milestones_without_dates(self, p_send_email, p_ugt):
""" Test creating two milestones with no dates. """
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
user = tests.FakeUser()
user.username = "pingou"
with tests.user_set(self.app.application, user):
# Get the CSRF token
output = self.app.get("/test/settings")
output_text = output.get_data(as_text=True)
csrf_token = output_text.split(
'name="csrf_token" type="hidden" value="'
)[1].split('">')[0]
data = {
"milestones": [1, 2],
"milestone_1_name": "v1.0",
"milestone_2_name": "v2.0",
"milestone_1_date": "",
"milestone_2_date": "",
"csrf_token": csrf_token,
}
output = self.app.post(
"/test/update/milestones", data=data, follow_redirects=True
)
self.assertEqual(output.status_code, 200)
output_text = output.get_data(as_text=True)
# Check the redirect
self.assertIn(
"<title>Settings - test - Pagure</title>", output_text
)
self.assertIn(
'<h5 class="pl-2 font-weight-bold text-muted">'
"Project Settings</h5>\n",
output_text,
)
self.assertIn("Milestones updated", output_text)
# Check the result of the action -- Milestones recorded
self.session.commit()
repo = pagure.lib.query.get_authorized_project(
self.session, "test"
)
self.assertEqual(
repo.milestones,
{
"v1.0": {"active": False, "date": None},
"v2.0": {"active": False, "date": None},
},
)
开发者ID:pypingou,项目名称:pagure,代码行数:50,代码来源:test_pagure_flask_ui_roadmap.py
示例15: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureLibGitMirrorProjecttests, self).setUp()
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
# Make the test project mirrored from elsewhere
self.project = pagure.lib.query.get_authorized_project(
self.session, "test"
)
self.project.mirrored_from = "https://example.com/foo/bar.git"
self.session.add(self.project)
self.session.commit()
开发者ID:pypingou,项目名称:pagure,代码行数:14,代码来源:test_pagure_lib_git_mirror_project.py
示例16: test_api_new_issue
def test_api_new_issue(self):
""" Test the api_new_issue method of the flask api. """
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(tests.HERE, "tickets"))
tests.create_tokens(self.session)
tests.create_tokens_acl(self.session)
headers = {"Authorization": "token aaabbbcccddd"}
# Valid token, wrong project
output = self.app.post("/api/0/test2/new_issue", headers=headers)
self.assertEqual(output.status_code, 401)
data = json.loads(output.data)
self.assertDictEqual(
data,
{
"error": "Invalid or expired token. Please visit "
"https://pagure.org/ to get or renew your API token.",
"error_code": "EINVALIDTOK",
},
)
# No input
output = self.app.post("/api/0/test/new_issue", headers=headers)
self.assertEqual(output.status_code, 400)
data = json.loads(output.data)
self.assertDictEqual(data, {"error": "Invalid or incomplete input submited", "error_code": "EINVALIDREQ"})
data = {"title": "test issue"}
# Invalid repo
output = self.app.post("/api/0/foo/new_issue", data=data, headers=headers)
self.assertEqual(output.status_code, 404)
data = json.loads(output.data)
self.assertDictEqual(data, {"error": "Project not found", "error_code": "ENOPROJECT"})
# Incomplete request
output = self.app.post("/api/0/test/new_issue", data=data, headers=headers)
self.assertEqual(output.status_code, 400)
data = json.loads(output.data)
self.assertDictEqual(data, {"error": "Invalid or incomplete input submited", "error_code": "EINVALIDREQ"})
data = {"title": "test issue", "issue_content": "This issue needs attention"}
# Valid request
output = self.app.post("/api/0/test/new_issue", data=data, headers=headers)
self.assertEqual(output.status_code, 200)
data = json.loads(output.data)
self.assertDictEqual(data, {"message": "Issue created"})
开发者ID:aavrug,项目名称:pagure,代码行数:49,代码来源:test_progit_flask_api_issue.py
示例17: test_ticket_with_priorities
def test_ticket_with_priorities(self, p_send_email, p_ugt):
""" Test creating a ticket with priorities. """
p_send_email.return_value = True
p_ugt.return_value = True
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(tests.HERE), bare=True)
# Set some priorities
repo = pagure.lib.get_project(self.session, 'test')
repo.priorities = {'1': 'High', '2': 'Normal'}
self.session.add(repo)
self.session.commit()
user = tests.FakeUser()
user.username = 'pingou'
with tests.user_set(pagure.APP, user):
# Get the CSRF token
output = self.app.get('/test/new_issue')
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<div class="card-header">\n New issue'
in output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'title': 'Test issue',
'issue_content': 'We really should improve on this issue',
'status': 'Open',
'csrf_token': csrf_token,
}
# Create the issue
output = self.app.post(
'/test/new_issue', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertIn(
'<title>Issue #1: Test issue - test - Pagure</title>',
output.data)
self.assertIn(
'<a class="btn btn-primary btn-sm" '
'href="/test/issue/1/edit" title="Edit this issue">',
output.data)
self.assertIn('<div id="priority_plain">', output.data)
self.assertIn('<option value="1">High</option>', output.data)
开发者ID:0-T-0,项目名称:pagure,代码行数:48,代码来源:test_pagure_flask_ui_priorities.py
示例18: test_ticket_with_no_roadmap
def test_ticket_with_no_roadmap(self, p_send_email, p_ugt):
""" Test creating a ticket without roadmap. """
p_send_email.return_value = True
p_ugt.return_value = True
tests.create_projects(self.session)
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
user = tests.FakeUser()
user.username = "pingou"
with tests.user_set(self.app.application, user):
# Get the CSRF token
output = self.app.get("/test/new_issue")
self.assertEqual(output.status_code, 200)
output_text = output.get_data(as_text=True)
self.assertTrue(
'<h4 class="font-weight-bold mb-4">New Issue</h4>\n'
in output_text
)
csrf_token = output_text.split(
'name="csrf_token" type="hidden" value="'
)[1].split('">')[0]
data = {
"title": "Test issue",
"issue_content": "We really should improve on this issue",
"status": "Open",
"csrf_token": csrf_token,
}
# Create the issue
output = self.app.post(
"/test/new_issue", data=data, follow_redirects=True
)
self.assertEqual(output.status_code, 200)
output_text = output.get_data(as_text=True)
self.assertIn(
"<title>Issue #1: Test issue - test - Pagure</title>",
output_text,
)
self.assertIn(
'<a class="btn btn-outline-secondary btn-sm border-0" '
'href="/test/issue/1/edit" title="Edit this issue">',
output_text,
)
开发者ID:pypingou,项目名称:pagure,代码行数:47,代码来源:test_pagure_flask_ui_roadmap.py
示例19: test_view_docs_project_no_docs
def test_view_docs_project_no_docs(self):
""" Test the view_docs endpoint with a project that disabled the
docs.
"""
tests.create_projects(self.session)
repo = pagure.lib.query.get_authorized_project(self.session, "test")
tests.create_projects_git(os.path.join(self.path, "repos", "docs"))
output = self.app.get("/test/docs")
self.assertEqual(output.status_code, 404)
repo.settings = {"project_documentation": False}
self.session.add(repo)
self.session.commit()
output = self.app.get("/test/docs", follow_redirects=True)
self.assertEqual(output.status_code, 404)
开发者ID:pypingou,项目名称:pagure,代码行数:17,代码来源:test_pagure_flask_docs.py
示例20: test_view_docs_project_no_docs
def test_view_docs_project_no_docs(self):
""" Test the view_docs endpoint with a project that disabled the
docs.
"""
tests.create_projects(self.session)
repo = pagure.lib.get_project(self.session, 'test')
tests.create_projects_git(os.path.join(tests.HERE, 'docs'))
output = self.app.get('/test/docs')
self.assertEqual(output.status_code, 404)
repo.settings = {'project_documentation': False}
self.session.add(repo)
self.session.commit()
output = self.app.get('/test/docs', follow_redirects=True)
self.assertEqual(output.status_code, 404)
开发者ID:girish946,项目名称:pagure,代码行数:17,代码来源:test_pagure_flask_docs.py
注:本文中的tests.create_projects_git函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论