本文整理汇总了Python中mdn.scrape.ScrapedViewFeature.new_browser方法的典型用法代码示例。如果您正苦于以下问题:Python ScrapedViewFeature.new_browser方法的具体用法?Python ScrapedViewFeature.new_browser怎么用?Python ScrapedViewFeature.new_browser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mdn.scrape.ScrapedViewFeature
的用法示例。
在下文中一共展示了ScrapedViewFeature.new_browser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_load_compat_table_new_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import new_browser [as 别名]
def test_load_compat_table_new_resources(self):
browser_id = "_Firefox (Gecko)"
version_id = "_Firefox-1.0"
feature_id = "_contain_and_cover"
support_id = "_%s-%s" % (feature_id, version_id)
scraped_data = self.empty_scrape()
scraped_table = {
"name": "desktop",
"browsers": [{"id": browser_id, "name": "Firefox", "slug": "_Firefox (Gecko)"}],
"versions": [{"id": version_id, "browser": browser_id, "version": "1.0"}],
"features": [
{
"id": feature_id,
"name": "<code>contain</code> and <code>cover</code>",
"slug": "web-css-background-size_contain_and_cover",
}
],
"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()
browser_content = view.new_browser(scraped_table["browsers"][0])
version_content = view.new_version(scraped_table["versions"][0])
feature_content = view.new_feature(scraped_table["features"][0])
support_content = view.new_support(scraped_table["supports"][0])
expected = self.empty_view(scraped_data)
expected["linked"]["browsers"].append(browser_content)
expected["linked"]["versions"].append(version_content)
expected["linked"]["features"].append(feature_content)
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)
示例2: test_new_browser
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import new_browser [as 别名]
def test_new_browser(self):
browser_entry = {
'id': '_Firefox (Gecko)', 'name': 'Firefox',
'slug': '_Firefox (Gecko)'}
view = ScrapedViewFeature(self.page, self.empty_scrape())
browser_content = view.new_browser(browser_entry)
expected = {
'id': '_Firefox (Gecko)', 'name': {'en': 'Firefox'}, 'note': None,
'slug': ''}
self.assertDataEqual(expected, browser_content)
示例3: test_load_compat_table_new_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import new_browser [as 别名]
def test_load_compat_table_new_resources(self):
browser_id = '_Firefox (Gecko)'
version_id = '_Firefox-1.0'
feature_id = '_contain_and_cover'
support_id = '_%s-%s' % (feature_id, version_id)
scraped_data = self.empty_scrape()
scraped_table = {
'name': 'desktop',
'browsers': [{
'id': browser_id, 'name': 'Firefox',
'slug': '_Firefox (Gecko)'}],
'versions': [{
'id': version_id, 'browser': browser_id, 'version': '1.0'}],
'features': [{
'id': feature_id,
'name': '<code>contain</code> and <code>cover</code>',
'slug': 'web-css-background-size_contain_and_cover'}],
'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()
browser_content = view.new_browser(scraped_table['browsers'][0])
version_content = view.new_version(scraped_table['versions'][0])
feature_content = view.new_feature(scraped_table['features'][0])
feature_content['links']['supports'].append(support_id)
support_content = view.new_support(scraped_table['supports'][0])
expected = self.empty_view(scraped_data)
expected['features']['links']['children'] = [feature_id]
expected['linked']['browsers'].append(browser_content)
expected['linked']['versions'].append(version_content)
expected['linked']['features'].append(feature_content)
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)
示例4: test_new_browser
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import new_browser [as 别名]
def test_new_browser(self):
browser_entry = {"id": "_Firefox (Gecko)", "name": "Firefox", "slug": "_Firefox (Gecko)"}
view = ScrapedViewFeature(self.page, self.empty_scrape())
browser_content = view.new_browser(browser_entry)
expected = {"id": "_Firefox (Gecko)", "name": {"en": "Firefox"}, "note": None, "slug": ""}
self.assertDataEqual(expected, browser_content)