當前位置: 首頁>>代碼示例>>Python>>正文


Python ScrapedViewFeature.load_version方法代碼示例

本文整理匯總了Python中mdn.scrape.ScrapedViewFeature.load_version方法的典型用法代碼示例。如果您正苦於以下問題:Python ScrapedViewFeature.load_version方法的具體用法?Python ScrapedViewFeature.load_version怎麽用?Python ScrapedViewFeature.load_version使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mdn.scrape.ScrapedViewFeature的用法示例。


在下文中一共展示了ScrapedViewFeature.load_version方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_load_compat_table_existing_resources

# 需要導入模塊: from mdn.scrape import ScrapedViewFeature [as 別名]
# 或者: from mdn.scrape.ScrapedViewFeature import load_version [as 別名]
 def test_load_compat_table_existing_resources(self):
     version = self.get_instance("Version", ("firefox_desktop", "1.0"))
     browser = version.browser
     feature = self.get_instance("Feature", "web-css-background-size-contain_and_cover")
     support = self.create(Support, version=version, feature=feature)
     browser_id = str(browser.id)
     version_id = str(version.id)
     feature_id = str(feature.id)
     support_id = str(support.id)
     scraped_data = self.empty_scrape()
     scraped_table = {
         "name": "desktop",
         "browsers": [{"id": browser_id, "name": browser.name["en"], "slug": browser.slug}],
         "versions": [{"id": version_id, "browser": browser_id, "version": "1.0"}],
         "features": [{"id": feature_id, "name": feature.name["en"], "slug": feature.slug}],
         "supports": [{"id": support_id, "feature": feature_id, "version": version_id, "support": "yes"}],
     }
     scraped_data["compat"].append(scraped_table)
     view = ScrapedViewFeature(self.page, scraped_data)
     out = view.generate_data()
     expected = self.empty_view(scraped_data)
     expected["linked"]["browsers"].append(view.load_browser(browser.id))
     expected["linked"]["versions"].append(view.load_version(version.id))
     expected["linked"]["features"].append(view.load_feature(feature.id))
     expected["linked"]["supports"].append(view.load_support(support.id))
     expected["meta"]["compat_table"]["supports"][feature_id] = {browser_id: [support_id]}
     expected["meta"]["compat_table"]["tabs"].append({"name": {"en": "Desktop Browsers"}, "browsers": [browser_id]})
     self.assertDataEqual(expected, out)
開發者ID:renoirb,項目名稱:browsercompat,代碼行數:30,代碼來源:test_scrape.py

示例2: test_load_compat_table_basic_support

# 需要導入模塊: from mdn.scrape import ScrapedViewFeature [as 別名]
# 或者: from mdn.scrape.ScrapedViewFeature import load_version [as 別名]
 def test_load_compat_table_basic_support(self):
     version = self.get_instance("Version", ("firefox_desktop", "1.0"))
     browser = version.browser
     feature = self.feature
     browser_id = str(browser.id)
     version_id = str(version.id)
     feature_id = str(feature.id)
     support_id = "_%s-%s" % (feature_id, version_id)
     scraped_data = self.empty_scrape()
     scraped_table = {
         "name": "desktop",
         "browsers": [{"id": browser_id, "name": browser.name["en"], "slug": browser.slug}],
         "versions": [{"id": version_id, "browser": browser_id, "version": "1.0"}],
         "features": [{"id": feature_id, "name": "Basic Support", "slug": feature.slug}],
         "supports": [{"id": support_id, "feature": feature_id, "version": version_id, "support": "yes"}],
     }
     scraped_data["compat"].append(scraped_table)
     view = ScrapedViewFeature(self.page, scraped_data)
     out = view.generate_data()
     expected = self.empty_view(scraped_data)
     expected["linked"]["browsers"].append(view.load_browser(browser.id))
     expected["linked"]["versions"].append(view.load_version(version.id))
     support_content = view.new_support(scraped_table["supports"][0])
     expected["linked"]["supports"].append(support_content)
     expected["meta"]["compat_table"]["supports"][feature_id] = {browser_id: [support_id]}
     expected["meta"]["compat_table"]["tabs"].append({"name": {"en": "Desktop Browsers"}, "browsers": [browser_id]})
     self.assertDataEqual(expected, out)
開發者ID:renoirb,項目名稱:browsercompat,代碼行數:29,代碼來源:test_scrape.py

示例3: test_load_version

# 需要導入模塊: from mdn.scrape import ScrapedViewFeature [as 別名]
# 或者: from mdn.scrape.ScrapedViewFeature import load_version [as 別名]
 def test_load_version(self):
     version = self.get_instance('Version', ('firefox_desktop', '1.0'))
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     version_content = view.load_version(version.id)
     expected = {
         'id': str(version.id), 'version': '1.0', 'status': 'unknown',
         'note': None, 'release_day': None, 'retirement_day': None,
         'release_notes_uri': None, 'order': 0,
         'links': {'browser': str(version.browser_id)}}
     self.assertDataEqual(expected, version_content)
開發者ID:MatonAnthony,項目名稱:browsercompat,代碼行數:12,代碼來源:test_scrape.py

示例4: test_load_version

# 需要導入模塊: from mdn.scrape import ScrapedViewFeature [as 別名]
# 或者: from mdn.scrape.ScrapedViewFeature import load_version [as 別名]
 def test_load_version(self):
     version = self.get_instance("Version", ("firefox_desktop", "1.0"))
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     version_content = view.load_version(version.id)
     expected = {
         "id": str(version.id),
         "version": "1.0",
         "status": "unknown",
         "note": None,
         "release_day": None,
         "retirement_day": None,
         "release_notes_uri": None,
         "order": 0,
         "links": {"browser": str(version.browser_id)},
     }
     self.assertDataEqual(expected, version_content)
開發者ID:renoirb,項目名稱:browsercompat,代碼行數:18,代碼來源:test_scrape.py

示例5: test_load_compat_table_existing_resources

# 需要導入模塊: from mdn.scrape import ScrapedViewFeature [as 別名]
# 或者: from mdn.scrape.ScrapedViewFeature import load_version [as 別名]
 def test_load_compat_table_existing_resources(self):
     version = self.get_instance('Version', ('firefox_desktop', '1.0'))
     browser = version.browser
     feature = self.get_instance(
         'Feature', 'web-css-background-size-contain_and_cover')
     support = self.create(Support, version=version, feature=feature)
     browser_id = str(browser.id)
     version_id = str(version.id)
     feature_id = str(feature.id)
     support_id = str(support.id)
     scraped_data = self.empty_scrape()
     scraped_table = {
         'name': 'desktop',
         'browsers': [{
             'id': browser_id, 'name': browser.name['en'],
             'slug': browser.slug}],
         'versions': [{
             'id': version_id, 'browser': browser_id, 'version': '1.0'}],
         'features': [{
             'id': feature_id, 'name': feature.name['en'],
             'slug': feature.slug}],
         'supports': [{
             'id': support_id, 'feature': feature_id, 'version': version_id,
             'support': 'yes'}]}
     scraped_data['compat'].append(scraped_table)
     view = ScrapedViewFeature(self.page, scraped_data)
     out = view.generate_data()
     expected = self.empty_view(scraped_data)
     expected['features']['links']['children'] = [feature_id]
     expected['linked']['browsers'].append(view.load_browser(browser.id))
     expected['linked']['versions'].append(view.load_version(version.id))
     expected['linked']['features'].append(view.load_feature(feature.id))
     expected['linked']['supports'].append(view.load_support(support.id))
     expected['meta']['compat_table']['supports'][feature_id] = {
         browser_id: [support_id]}
     expected['meta']['compat_table']['tabs'].append({
         'name': {'en': 'Desktop Browsers'},
         'browsers': [browser_id]})
     self.assertDataEqual(expected, out)
開發者ID:MatonAnthony,項目名稱:browsercompat,代碼行數:41,代碼來源:test_scrape.py


注:本文中的mdn.scrape.ScrapedViewFeature.load_version方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。