当前位置: 首页>>代码示例>>Python>>正文


Python Library.put方法代码示例

本文整理汇总了Python中datamodel.Library.put方法的典型用法代码示例。如果您正苦于以下问题:Python Library.put方法的具体用法?Python Library.put怎么用?Python Library.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在datamodel.Library的用法示例。


在下文中一共展示了Library.put方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_normal

# 需要导入模块: from datamodel import Library [as 别名]
# 或者: from datamodel.Library import put [as 别名]
  def test_normal(self):
    headers = {'X-Github-Event': 'pull_request'}
    payload = {
        'action': 'opened',
        'repository': {
            'owner': {'login': 'owner'},
            'name': 'repo',
            'full_name': 'owner/repo'
        },
        'pull_request': {
            'head': {
                'sha': 'sha',
                'repo': {
                    'owner': {'login': 'pull_owner'},
                    'name': 'pull_repo',
                    'full_name': 'pull_owner/pull_repo'
                }
            },
            'url': 'github_pr_url'
        }
    }
    library = Library(id='owner/repo')
    library.put()

    self.respond_to('https://api.github.com/repos/owner/repo/statuses', {'status': 201})
    self.app.post('/api/preview-event', params=json.dumps(payload), headers=headers, status=200)
    tasks = self.tasks.get_filtered_tasks()
    self.assertEqual(len(tasks), 1)
开发者ID:customelements,项目名称:v2,代码行数:30,代码来源:api_test.py

示例2: test_update_suppressed_is_noop

# 需要导入模块: from datamodel import Library [as 别名]
# 或者: from datamodel.Library import put [as 别名]
  def test_update_suppressed_is_noop(self):
    library = Library(id='org/repo', status=Status.suppressed, spdx_identifier='MIT')
    library.put()
    response = self.app.get('/task/update/org/repo', headers={'X-AppEngine-QueueName': 'default'})
    self.assertEqual(response.status_int, 200)
    tasks = self.tasks.get_filtered_tasks()
    self.assertEqual(len(tasks), 0)

    library = library.key.get()
    self.assertEqual(library.status, Status.suppressed)
开发者ID:andymutton,项目名称:v2,代码行数:12,代码来源:manage_test.py

示例3: test_update_respects_304

# 需要导入模块: from datamodel import Library [as 别名]
# 或者: from datamodel.Library import put [as 别名]
  def test_update_respects_304(self):
    library = Library(id='org/repo', metadata_etag='a', contributors_etag='b', tags_etag='c', tag_map='{}', spdx_identifier='MIT')
    library.put()
    self.respond_to_github('https://api.github.com/repos/org/repo', {'status': 304})
    self.respond_to_github('https://api.github.com/repos/org/repo/contributors', {'status': 304})
    self.respond_to_github('https://api.github.com/repos/org/repo/tags', {'status': 304})
    self.respond_to_github('https://api.github.com/repos/org/repo/stats/participation', '{}')

    response = self.app.get('/task/update/org/repo', headers={'X-AppEngine-QueueName': 'default'})
    self.assertEqual(response.status_int, 200)
    tasks = self.tasks.get_filtered_tasks()
    self.assertEqual(len(tasks), 0)
开发者ID:andymutton,项目名称:v2,代码行数:14,代码来源:manage_test.py

示例4: test_update_deletes_missing_repo

# 需要导入模块: from datamodel import Library [as 别名]
# 或者: from datamodel.Library import put [as 别名]
  def test_update_deletes_missing_repo(self):
    library = Library(id='org/repo', metadata_etag='a', contributors_etag='b', tags_etag='c', spdx_identifier='MIT')
    library.put()
    version = Version(parent=library.key, id='v1.0.0', sha='lol')
    version.put()

    self.respond_to_github('https://api.github.com/repos/org/repo', {'status': 404})
    response = self.app.get('/task/update/org/repo', headers={'X-AppEngine-QueueName': 'default'})
    self.assertEqual(response.status_int, 200)

    version = version.key.get()
    library = library.key.get()

    self.assertIsNone(library)
    self.assertIsNone(version)
开发者ID:andymutton,项目名称:v2,代码行数:17,代码来源:manage_test.py

示例5: test_renamed_repo_is_renamed

# 需要导入模块: from datamodel import Library [as 别名]
# 或者: from datamodel.Library import put [as 别名]
  def test_renamed_repo_is_renamed(self):
    library = Library(id='org/repo', metadata_etag='a', contributors_etag='b', tags_etag='c', tag_map='{}', spdx_identifier='MIT')
    library.put()
    self.respond_to_github('https://api.github.com/repos/org/repo', json.dumps({
        "name": "newname",
        "owner": {"login": "newowner"},
    }))

    response = self.app.get('/task/update/org/repo', headers={'X-AppEngine-QueueName': 'default'})
    self.assertEqual(response.status_int, 200)

    library = library.key.get()
    self.assertIsNone(library)

    tasks = self.tasks.get_filtered_tasks()
    self.assertEqual([
        util.ensure_library_task('newowner', 'newname'),
    ], [task.url for task in tasks])
开发者ID:andymutton,项目名称:v2,代码行数:20,代码来源:manage_test.py

示例6: test_ingest_version_falls_back

# 需要导入模块: from datamodel import Library [as 别名]
# 或者: from datamodel.Library import put [as 别名]
  def test_ingest_version_falls_back(self):
    library = Library(id='org/repo', metadata='{"full_name": "NSS Bob", "stargazers_count": 420, "subscribers_count": 419, "forks": 418, "updated_at": "2011-8-10T13:47:12Z"}', contributor_count=417)
    library.tags = json.dumps(["v1.0.0", "v1.0.1"])
    library.put()
    version1 = Version(parent=library.key, id='v1.0.0', sha='lol')
    version1.put()
    version2 = Version(parent=library.key, id='v1.0.1', sha='lol')
    version2.put()

    self.respond_to('https://raw.githubusercontent.com/org/repo/v1.0.1/README.md', chr(248))

    tasks = self.tasks.get_filtered_tasks()
    self.assertEqual(len(tasks), 0)

    self.app.get(util.ingest_version_task('org', 'repo', 'v1.0.1'), params={'latestVersion': 'True'})

    version2 = version2.key.get()
    self.assertEqual(version2.error, "Could not store README.md as a utf-8 string")

    tasks = self.tasks.get_filtered_tasks()
    self.assertEqual(len(tasks), 1)
    self.assertEqual(tasks[0].url, util.ingest_version_task('org', 'repo', 'v1.0.0') + '?latestVersion=True')
开发者ID:samuelli,项目名称:v2,代码行数:24,代码来源:manage_test.py

示例7: test_ingest_version

# 需要导入模块: from datamodel import Library [as 别名]
# 或者: from datamodel.Library import put [as 别名]
  def test_ingest_version(self):
    library = Library(id='org/repo', metadata='{"full_name": "NSS Bob", "stargazers_count": 420, "subscribers_count": 419, "forks": 418, "updated_at": "2011-8-10T13:47:12Z"}', contributor_count=417)
    version = Version(parent=library.key, id='v1.0.0', sha='lol')
    library.put()
    version.put()

    self.respond_to('https://raw.githubusercontent.com/org/repo/v1.0.0/README.md', 'README')
    self.respond_to('https://raw.githubusercontent.com/org/repo/v1.0.0/bower.json', '{}')
    self.respond_to_github('https://api.github.com/markdown', '<html>README</html>')

    response = self.app.get(util.ingest_version_task('org', 'repo', 'v1.0.0'))
    self.assertEqual(response.status_int, 200)

    version = version.key.get()
    self.assertIsNone(version.error)

    readme = ndb.Key(Library, 'org/repo', Version, 'v1.0.0', Content, 'readme').get()
    self.assertEqual(readme.content, 'README')
    readme_html = ndb.Key(Library, 'org/repo', Version, 'v1.0.0', Content, 'readme.html').get()
    self.assertEqual(readme_html.content, '<html>README</html>')
    bower = ndb.Key(Library, 'org/repo', Version, 'v1.0.0', Content, 'bower').get()
    self.assertEqual(bower.content, '{}')
开发者ID:samuelli,项目名称:v2,代码行数:24,代码来源:manage_test.py


注:本文中的datamodel.Library.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。