本文整理汇总了Python中tests.create_projects函数的典型用法代码示例。如果您正苦于以下问题:Python create_projects函数的具体用法?Python create_projects怎么用?Python create_projects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_projects函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_view_raw_file
def test_view_raw_file(self, send_email):
""" Test the view_raw_file endpoint when the git repo has no
master branch.
"""
send_email.return_value = True
tests.create_projects(self.session)
# Non-existant git repo
output = self.app.get("/test/raw/master")
self.assertEqual(output.status_code, 404)
output = self.app.get("/test/raw/master/f/sources")
self.assertEqual(output.status_code, 404)
self.set_up_git_repo()
# With git repo
output = self.app.get("/test/raw/master")
self.assertEqual(output.status_code, 404)
output = self.app.get("/test/raw/master/f/sources")
self.assertEqual(output.status_code, 404)
output = self.app.get("/test/raw/feature")
self.assertEqual(output.status_code, 200)
output_text = output.get_data(as_text=True)
self.assertIn("diff --git a/.gitignore b/.gitignore", output_text)
self.assertIn("+*~", output_text)
output = self.app.get("/test/raw/feature/f/sources")
self.assertEqual(output.status_code, 200)
self.assertEqual("foo\n bar", output.get_data(as_text=True))
开发者ID:pypingou,项目名称:pagure,代码行数:30,代码来源:test_pagure_flask_ui_no_master_branch.py
示例2: test_view_commits
def test_view_commits(self, send_email):
""" Test the view_commits endpoint when the git repo has no
master branch.
"""
send_email.return_value = True
tests.create_projects(self.session)
# Non-existant git repo
output = self.app.get('/test/commits')
self.assertEqual(output.status_code, 404)
self.set_up_git_repo()
# With git repo
output = self.app.get('/test/commits')
self.assertEqual(output.status_code, 200)
self.assertIn(
'<div class="list-group m-t-1">\n </div>', output.data)
self.assertNotIn(
'<div class="btn-group pull-xs-right">', output.data)
output = self.app.get('/test/commits/feature')
self.assertEqual(output.status_code, 200)
self.assertIn(
'<div class="container p-t-3">\n <div class="row m-b-1">',
output.data)
self.assertIn('Add sources file for testing', output.data)
self.assertIn('Add .gitignore file for testing', output.data)
self.assertNotIn(
'<div class="list-group m-t-1">\n </div>', output.data)
self.assertEqual(
output.data.count('class="list-group-item p-l-3"'), 2)
开发者ID:trasher,项目名称:ProGit,代码行数:32,代码来源:test_pagure_flask_ui_no_master_branch.py
示例3: test_view_tree
def test_view_tree(self, send_email):
""" Test the view_tree endpoint when the git repo has no
master branch.
"""
send_email.return_value = True
tests.create_projects(self.session)
# Non-existant git repo
output = self.app.get('/test/tree/')
self.assertEqual(output.status_code, 404)
output = self.app.get('/test/tree/master')
self.assertEqual(output.status_code, 404)
self.set_up_git_repo()
# With git repo
output = self.app.get('/test/tree/master')
self.assertEqual(output.status_code, 200)
self.assertIn('No content found in this repository', output.data)
output = self.app.get('/test/tree/master/sources')
self.assertEqual(output.status_code, 200)
self.assertIn('No content found in this repository', output.data)
output = self.app.get('/test/tree/feature')
self.assertEqual(output.status_code, 200)
self.assertIn('<a href="/test/blob/feature/f/sources">', output.data)
self.assertIn(
'<td class-"pagure-table-filehex">\n'
' 9f4435\n </td>',
output.data)
output = self.app.get('/test/tree/feature/sources')
self.assertEqual(output.status_code, 200)
self.assertIn('No content found in this repository', output.data)
开发者ID:trasher,项目名称:ProGit,代码行数:34,代码来源:test_pagure_flask_ui_no_master_branch.py
示例4: test_new_request_pull
def test_new_request_pull(self, send_email):
""" Test the new_request_pull endpoint when the git repo has no
master branch.
"""
send_email.return_value = True
tests.create_projects(self.session)
# Non-existant git repo
output = self.app.get('/test/diff/master..maxamilion/feature')
# (used to be 302 but seeing a diff is allowed even logged out)
self.assertEqual(output.status_code, 404)
user = tests.FakeUser()
with tests.user_set(pagure.APP, user):
output = self.app.get('/test/diff/master..maxamilion/feature')
self.assertEqual(output.status_code, 404)
self.set_up_git_repo()
output = self.app.get('/test/diff/master..maxamilion/feature')
# (used to be 302 but seeing a diff is allowed even logged out)
self.assertEqual(output.status_code, 200)
self.assertEqual(
output.data.count('<span class="commitdate" title='), 1)
self.assertIn('<h5>.gitignore', output.data)
user = tests.FakeUser()
with tests.user_set(pagure.APP, user):
output = self.app.get('/test/diff/master..maxamilion/feature')
self.assertEqual(output.status_code, 200)
self.assertEqual(
output.data.count('<span class="commitdate" title='), 1)
self.assertIn('<h5>.gitignore', output.data)
开发者ID:rahulbajaj0509,项目名称:pagure,代码行数:33,代码来源:test_progit_flask_ui_slash_branch_name.py
示例5: test_index
def test_index(self):
""" Test the index endpoint. """
output = self.app.get("/")
self.assertEqual(output.status_code, 200)
self.assertIn('<h2 class=" m-b-1">All Projects ' '<span class="label label-default">0</span></h2>', output.data)
tests.create_projects(self.session)
output = self.app.get("/?page=abc")
self.assertEqual(output.status_code, 200)
self.assertIn('<h2 class=" m-b-1">All Projects ' '<span class="label label-default">2</span></h2>', output.data)
# Add a 3rd project with a long description
item = pagure.lib.model.Project(
user_id=2, # foo
name="test3",
description="test project #3 with a very long description",
hook_token="aaabbbeee",
)
self.session.add(item)
self.session.commit()
user = tests.FakeUser(username="foo")
with tests.user_set(pagure.APP, user):
output = self.app.get("/?repopage=abc&forkpage=def")
self.assertIn('Projects <span class="label label-default">1</span>', output.data)
self.assertIn('Forks <span class="label label-default">0</span>', output.data)
self.assertEqual(output.data.count("<p>No projects found</p>"), 1)
self.assertEqual(output.data.count("<p>No group found</p>"), 1)
self.assertEqual(output.data.count('<div class="card-header">'), 3)
开发者ID:rahulbajaj0509,项目名称:pagure,代码行数:31,代码来源:test_progit_flask_ui_app.py
示例6: setUp
def setUp(self):
super(PagureLibGitAuthtests, self).setUp()
tests.create_projects(self.session)
tests.create_tokens(self.session)
tests.create_tokens_acl(self.session)
self.create_project_full("hooktest")
开发者ID:pypingou,项目名称:pagure,代码行数:7,代码来源:test_pagure_lib_git_auth.py
示例7: test_view_commits
def test_view_commits(self, send_email):
""" Test the view_commits endpoint when the git repo has no
master branch.
"""
send_email.return_value = True
tests.create_projects(self.session)
# Non-existant git repo
output = self.app.get('/test/commits')
self.assertEqual(output.status_code, 404)
self.set_up_git_repo()
# With git repo
output = self.app.get('/test/commits')
self.assertEqual(output.status_code, 200)
self.assertIn(
'<h3>Commits list</h3>\n <ul>\n </ul>', output.data)
self.assertTrue(output.data.count('<a href="/test/branch/'), 1)
output = self.app.get('/test/commits/feature')
self.assertEqual(output.status_code, 200)
self.assertIn('<h3>Commits list</h3>', output.data)
self.assertIn('Add sources file for testing', output.data)
self.assertIn('Add .gitignore file for testing', output.data)
self.assertNotIn(
'<h3>Commits list</h3>\n <ul>\n </ul>', output.data)
self.assertTrue(output.data.count('<a href="/test/branch/'), 1)
开发者ID:girish946,项目名称:pagure,代码行数:28,代码来源:test_progit_flask_ui_no_master_branch.py
示例8: test_watch_list
def test_watch_list(self):
''' Test for watch list of a user '''
user = tests.FakeUser(username='pingou')
with tests.user_set(pagure.APP, user):
output = self.app.get('/')
self.assertIn(
'<div class="text-xs-center">You have no projects</div>',
output.data)
self.assertIn(
'<p>You have no forks</p>',
output.data)
self.assertIn(
'<p>No project in watch list</p>',
output.data)
tests.create_projects(self.session)
output = self.app.get('/')
self.assertIn(
'My Projects <span class="label label-default">2</span>',
output.data)
self.assertIn(
'My Forks <span class="label label-default">0</span>',
output.data)
self.assertIn(
'My Watch List <span class="label label-default">2</span>',
output.data)
开发者ID:denys-duchier,项目名称:pagure,代码行数:28,代码来源:test_pagure_flask_ui_app.py
示例9: test_view_file
def test_view_file(self, send_email):
""" Test the view_file endpoint when the git repo has no
master branch.
"""
send_email.return_value = True
tests.create_projects(self.session)
# Non-existant git repo
output = self.app.get("/test/blob/master/f/sources")
self.assertEqual(output.status_code, 404)
self.set_up_git_repo()
# With git repo
output = self.app.get("/test/blob/master/f/sources")
self.assertEqual(output.status_code, 404)
output = self.app.get("/test/blob/feature/f/sources")
self.assertEqual(output.status_code, 200)
self.assertIn(
'<a href="/test/tree/feature">' '<span class="oi" data-glyph="random"></span> feature</a>',
output.data,
)
self.assertIn(
'</li><li class="active"><span class="oi" data-glyph="file">' "</span> sources</li>", output.data
)
self.assertIn('<td class="cell2"><pre>foo</pre></td>', output.data)
开发者ID:jepio,项目名称:pagure,代码行数:27,代码来源:test_pagure_flask_ui_no_master_branch.py
示例10: test_http_push
def test_http_push(self):
""" Test that the HTTP push endpoint works for repoSpanner. """
tests.create_projects(self.session)
tests.create_tokens(self.session)
tests.create_tokens_acl(self.session)
self.create_project_full("clonetest", {"create_readme": "y"})
# Verify the new project is indeed on repoSpanner
project = pagure.lib.query._get_project(self.session, "clonetest")
self.assertTrue(project.is_on_repospanner)
# Unfortunately, actually testing a git clone would need the app to
# run on a TCP port, which the test environment doesn't do.
output = self.app.get(
"/clonetest.git/info/refs?service=git-receive-pack",
environ_overrides={"REMOTE_USER": "pingou"},
)
self.assertEqual(output.status_code, 200)
self.assertEqual(
output.content_type, "application/x-git-receive-pack-advertisement"
)
output_text = output.get_data(as_text=True)
self.assertIn("# service=git-receive-pack", output_text)
self.assertIn("agent=repoSpanner", output_text)
self.assertIn("symref=HEAD:refs/heads/master", output_text)
self.assertIn(" refs/heads/master\x00", output_text)
开发者ID:pypingou,项目名称:pagure,代码行数:26,代码来源:test_pagure_repospanner.py
示例11: test_index_logged_in
def test_index_logged_in(self):
"""
Test the index endpoint when logged in.
It should redirect to the userdash.
"""
tests.create_projects(self.session)
# Add a 3rd project with a long description
item = pagure.lib.model.Project(
user_id=2, # foo
name="test3",
description="test project #3 with a very long description",
hook_token="aaabbbeeefff",
)
self.session.add(item)
self.session.commit()
user = tests.FakeUser(username="foo")
with tests.user_set(self.app.application, user):
output = self.app.get("/", follow_redirects=True)
self.assertEqual(output.status_code, 200)
output_text = output.get_data(as_text=True)
self.assertIn(
'<span class="btn btn-outline-secondary disabled '
'opacity-100 border-0 ml-auto font-weight-bold">'
"1 Projects</span>\n",
output_text,
)
self.assertNotIn(
'<h3 class="m-0 font-weight-bold">All Projects '
'<span class="badge badge-secondary">3</span></h3>',
output_text,
)
开发者ID:pypingou,项目名称:pagure,代码行数:33,代码来源:test_pagure_flask_ui_app_index.py
示例12: 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
示例13: setUp
def setUp(self):
super(PagureLibGitAuthPagureGitAuthtests, self).setUp()
tests.create_projects(self.session)
tests.create_tokens(self.session)
tests.create_tokens_acl(self.session)
self.create_project_full("acltest")
project = pagure.lib.query._get_project(self.session, "acltest")
# Create non-push deploy key
non_push_dkey = pagure.lib.model.SSHKey(
project_id=project.id,
pushaccess=False,
public_ssh_key="\n foo bar",
ssh_short_key="\n foo bar",
ssh_search_key="\n foo bar",
creator_user_id=1, # pingou
)
self.session.add(non_push_dkey)
# Create push deploy key
push_dkey = pagure.lib.model.SSHKey(
project_id=project.id,
pushaccess=True,
public_ssh_key="\n bar foo",
ssh_short_key="\n bar foo",
ssh_search_key="\n bar foo",
creator_user_id=1, # pingou
)
self.session.add(push_dkey)
self.session.commit()
开发者ID:pypingou,项目名称:pagure,代码行数:29,代码来源:test_pagure_lib_git_auth_paguregitauth.py
示例14: test_view_repo
def test_view_repo(self, send_email):
""" Test the view_repo endpoint when the git repo has no master
branch.
"""
send_email.return_value = True
tests.create_projects(self.session)
# Non-existant git repo
output = self.app.get("/test")
self.assertEqual(output.status_code, 404)
self.set_up_git_repo()
# With git repo
output = self.app.get("/test")
self.assertEqual(output.status_code, 200)
output_text = output.get_data(as_text=True)
self.assertIn('<section class="no-readme">', output_text)
self.assertIn(
"The test project's README file is empty or unavailable.",
output_text,
)
self.assertEqual(
output_text.count('<a class="dropdown-item" href="/test/branch/'),
0,
)
开发者ID:pypingou,项目名称:pagure,代码行数:26,代码来源:test_pagure_flask_ui_no_master_branch.py
示例15: 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
示例16: setUp
def setUp(self):
""" Set up the environnment, ran before every tests. """
super(PagureLibAddUserToProjecttests, self).setUp()
tests.create_projects(self.session)
item = pagure.lib.model.User(
user="bar",
fullname="bar baz",
password="foo",
default_email="[email protected]",
)
self.session.add(item)
item = pagure.lib.model.UserEmail(user_id=3, email="[email protected]")
self.session.add(item)
self.session.commit()
# Before
repo = pagure.lib.query._get_project(self.session, "test")
self.assertEqual(len(repo.users), 0)
msg = pagure.lib.query.add_user_to_project(
session=self.session, project=repo, new_user="foo", user="pingou"
)
self.session.commit()
self.assertEqual(msg, "User added")
# After
repo = pagure.lib.query._get_project(self.session, "test")
self.assertEqual(len(repo.users), 1)
self.assertEqual(repo.users[0].user, "foo")
self.assertEqual(repo.admins[0].user, "foo")
开发者ID:pypingou,项目名称:pagure,代码行数:33,代码来源:test_pagure_lib_add_user_to_project.py
示例17: test_auth_expired
def test_auth_expired(self):
""" Test the authentication when the token has expired.
"""
tests.create_projects(self.session)
tests.create_tokens(self.session)
output = self.app.post('/api/0/test/new_issue')
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",
}
)
headers = {'Authorization': 'token expired_token'}
output = self.app.post('/api/0/test/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",
}
)
开发者ID:0-T-0,项目名称:pagure,代码行数:31,代码来源:test_pagure_flask_api_auth.py
示例18: test_index
def test_index(self):
""" Test the index endpoint. """
output = self.app.get('/')
self.assertEqual(output.status_code, 200)
self.assertTrue('<h2>All Projects (0)</h2>' in output.data)
tests.create_projects(self.session)
output = self.app.get('/?page=abc')
self.assertEqual(output.status_code, 200)
self.assertTrue('<h2>All Projects (2)</h2>' in output.data)
# Add a 3rd project with a long description
item = pagure.lib.model.Project(
user_id=2, # foo
name='test3',
description='test project #3 with a very long description',
hook_token='aaabbbeee',
)
self.session.add(item)
self.session.commit()
user = tests.FakeUser()
with tests.user_set(pagure.APP, user):
output = self.app.get('/?repopage=abc&forkpage=def')
self.assertTrue(
'<section class="project_list" id="repos">' in output.data)
self.assertTrue('<h3>My Forks (0)</h3>' in output.data)
self.assertTrue(
'<section class="project_list" id="myforks">' in output.data)
self.assertTrue('<h3>My Projects (0)</h3>' in output.data)
self.assertTrue(
'<section class="project_list" id="myrepos">' in output.data)
self.assertTrue('<h3>All Projects (3)</h3>' in output.data)
开发者ID:arielb2,项目名称:pagure,代码行数:35,代码来源:test_progit_flask_ui_app.py
示例19: test_auth
def test_auth(self):
""" Test the token based authentication.
"""
tests.create_projects(self.session)
tests.create_tokens(self.session)
tests.create_tokens_acl(self.session)
output = self.app.post('/api/0/test/new_issue')
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",
}
)
headers = {'Authorization': 'token aaabbbcccddd'}
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",
}
)
开发者ID:0-T-0,项目名称:pagure,代码行数:31,代码来源:test_pagure_flask_api_auth.py
示例20: test_view_tree
def test_view_tree(self, send_email):
""" Test the view_tree endpoint when the git repo has no
master branch.
"""
send_email.return_value = True
tests.create_projects(self.session)
# Non-existant git repo
output = self.app.get('/test/tree/')
self.assertEqual(output.status_code, 404)
output = self.app.get('/test/tree/master')
self.assertEqual(output.status_code, 404)
self.set_up_git_repo()
# With git repo
output = self.app.get('/test/tree/master')
self.assertEqual(output.status_code, 200)
self.assertIn('<a href="/test/blob/master/f/sources">', output.data)
self.assertEqual(
output.data.count('<span class="oi text-muted" data-glyph="file">'), 1)
output = self.app.get('/test/tree/master/sources')
self.assertEqual(output.status_code, 200)
self.assertIn('<a href="/test/blob/master/f/sources">', output.data)
self.assertEqual(
output.data.count('<span class="oi text-muted" data-glyph="file">'), 1)
output = self.app.get('/test/tree/feature')
self.assertEqual(output.status_code, 200)
self.assertIn('<a href="/test/blob/master/f/sources">', output.data)
self.assertIn(
'<td class-"pagure-table-filehex">\n'
' 9f4435', output.data)
self.assertEqual(
output.data.count('<span class="oi text-muted" data-glyph="file">'), 1)
output = self.app.get('/test/tree/maxamilion/feature')
self.assertEqual(output.status_code, 200)
self.assertIn(
'<a href="/test/blob/maxamilion/feature/f/sources">',
output.data)
self.assertIn(
'<td class-"pagure-table-filehex">\n'
' 9f4435', output.data)
self.assertIn(
'<td class-"pagure-table-filehex">\n'
' e4e5f6', output.data)
self.assertEqual(
output.data.count('<span class="oi text-muted" data-glyph="file">'), 2)
# Wrong identifier, back onto master
output = self.app.get('/test/tree/maxamilion/feature/f/.gitignore')
self.assertEqual(output.status_code, 200)
self.assertIn('<a href="/test/blob/master/f/sources">', output.data)
self.assertIn(
'<td class-"pagure-table-filehex">\n'
' 9f4435', output.data)
self.assertEqual(
output.data.count('<span class="oi text-muted" data-glyph="file">'), 1)
开发者ID:rahulbajaj0509,项目名称:pagure,代码行数:60,代码来源:test_progit_flask_ui_slash_branch_name.py
注:本文中的tests.create_projects函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论