本文整理汇总了Python中tests.create_projects函数的典型用法代码示例。如果您正苦于以下问题:Python create_projects函数的具体用法?Python create_projects怎么用?Python create_projects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_projects函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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))
示例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)
示例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)
示例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)
示例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)
示例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")
示例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)
示例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)
示例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)
示例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)
示例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,
)
示例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")
示例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()
示例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,
)
示例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"))