當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。