本文整理汇总了Python中mdn.scrape.ScrapedViewFeature.generate_data方法的典型用法代码示例。如果您正苦于以下问题:Python ScrapedViewFeature.generate_data方法的具体用法?Python ScrapedViewFeature.generate_data怎么用?Python ScrapedViewFeature.generate_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mdn.scrape.ScrapedViewFeature
的用法示例。
在下文中一共展示了ScrapedViewFeature.generate_data方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_load_compat_table_unicode_feature_name
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [as 别名]
def test_load_compat_table_unicode_feature_name(self):
# https://developer.mozilla.org/en-US/docs/Web/CSS/timing-function
browser_id = '_Firefox (Gecko)'
version_id = '_Firefox-1.0'
feature_id = '_cubic-bezier() w/ ordinate ∉[0,1]'
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>cubic-bezier()</code> w/ ordinate ∉[0,1]',
'slug': 'web-css-background-size_unicode'}],
'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()
self.assertEqual(feature_id, out['linked']['features'][0]['id'])
示例2: test_load_compat_table_basic_support
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [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_tabs = [
{'name': {'en': 'Desktop Browsers'}, 'browsers': [browser_id]}]
self.assertEqual(expected_tabs, out['meta']['compat_table']['tabs'])
示例3: test_load_compat_table_new_support_with_note
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [as 别名]
def test_load_compat_table_new_support_with_note(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')
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': feature.name['en'],
'slug': feature.slug}],
'supports': [{
'id': support_id, 'feature': feature_id, 'version': version_id,
'support': 'yes', 'footnote': 'Footnote'}]}
scraped_data['compat'].append(scraped_table)
view = ScrapedViewFeature(self.page, scraped_data)
out = view.generate_data()
self.assertEqual(1, out['meta']['compat_table']['notes'][support_id])
示例4: test_load_specification_row_empty_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [as 别名]
def test_load_specification_row_empty_resources(self):
scraped_data = self.empty_scrape()
scraped_spec = {
'section.note': '',
'section.subpath': '',
'section.name': '',
'specification.mdn_key': 'CSS3 UI',
'section.id': None,
'specification.id': None}
scraped_data['specs'].append(scraped_spec)
view = ScrapedViewFeature(self.page, scraped_data)
out = view.generate_data()
spec_content, mat_content = view.new_specification(scraped_spec)
section_content = view.new_section(scraped_spec, spec_content['id'])
# TODO: bug 1251252 - Empty string should mean omittied name, subpath
section_content['name']['en'] = ''
section_content['subpath']['en'] = ''
reference_content = view.load_or_new_reference(section_content['id'])
reference_content['note'] = None
expected = self.empty_view(scraped_data)
expected['features']['links']['references'] = [reference_content['id']]
expected['linked']['maturities'] = [mat_content]
expected['linked']['specifications'] = [spec_content]
expected['linked']['sections'] = [section_content]
expected['linked']['references'] = [reference_content]
self.assertDataEqual(expected, out)
示例5: test_load_specification_row_existing_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [as 别名]
def test_load_specification_row_existing_resources(self):
reference = self.get_instance(
'Reference', ('web-css-background-size', 'background-size'))
section = reference.section
spec = section.specification
scraped_spec = {
'section.note': 'new note',
'section.subpath': section.subpath['en'],
'section.name': section.name['en'],
'specification.mdn_key': spec.mdn_key,
'section.id': section.id,
'specification.id': spec.id}
scraped_data = self.empty_scrape()
scraped_data['specs'].append(scraped_spec)
view = ScrapedViewFeature(self.page, scraped_data)
out = view.generate_data()
expected = self.empty_view(scraped_data)
spec_content, mat_content = view.load_specification(spec.id)
section_content = view.load_section(section.id)
reference_content = view.load_or_new_reference(section.id)
reference_content['note'] = {'en': 'new note'}
expected['features']['links']['references'] = [reference_content['id']]
expected['linked']['maturities'] = [mat_content]
expected['linked']['specifications'] = [spec_content]
expected['linked']['sections'] = [section_content]
expected['linked']['references'] = [reference_content]
self.assertDataEqual(expected, out)
示例6: test_load_compat_table_basic_support
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [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)
示例7: test_load_compat_table_existing_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [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)
示例8: test_load_compat_table_new_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [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)
示例9: test_load_specification_row_new_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [as 别名]
def test_load_specification_row_new_resources(self):
scraped_data = self.empty_scrape()
scraped_spec = {
'section.note': 'section note',
'section.subpath': '#section',
'section.name': 'section',
'specification.mdn_key': 'CSS3 UI',
'section.id': None,
'specification.id': None}
scraped_data['specs'].append(scraped_spec)
view = ScrapedViewFeature(self.page, scraped_data)
out = view.generate_data()
spec_content, mat_content = view.new_specification(scraped_spec)
section_content = view.new_section(scraped_spec, spec_content['id'])
expected = self.empty_view(scraped_data)
expected['features']['links']['sections'] = [section_content['id']]
expected['linked']['maturities'] = [mat_content]
expected['linked']['specifications'] = [spec_content]
expected['linked']['sections'] = [section_content]
self.assertDataEqual(expected, out)
示例10: test_load_specification_row_new_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [as 别名]
def test_load_specification_row_new_resources(self):
scraped_data = self.empty_scrape()
scraped_spec = {
"section.note": "section note",
"section.subpath": "#section",
"section.name": "section",
"specification.mdn_key": "CSS3 UI",
"section.id": None,
"specification.id": None,
}
scraped_data["specs"].append(scraped_spec)
view = ScrapedViewFeature(self.page, scraped_data)
out = view.generate_data()
spec_content, mat_content = view.new_specification(scraped_spec)
section_content = view.new_section(scraped_spec, spec_content["id"])
expected = self.empty_view(scraped_data)
expected["features"]["links"]["sections"] = [section_content["id"]]
expected["linked"]["maturities"] = [mat_content]
expected["linked"]["specifications"] = [spec_content]
expected["linked"]["sections"] = [section_content]
self.assertDataEqual(expected, out)
示例11: test_load_compat_table_existing_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [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)
示例12: test_load_compat_table_new_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [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)
示例13: test_load_specification_row_existing_resources
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [as 别名]
def test_load_specification_row_existing_resources(self):
section = self.get_instance("Section", "background-size")
spec = section.specification
scraped_spec = {
"section.note": "new note",
"section.subpath": section.subpath["en"],
"section.name": section.name["en"],
"specification.mdn_key": spec.mdn_key,
"section.id": section.id,
"specification.id": spec.id,
}
scraped_data = self.empty_scrape()
scraped_data["specs"].append(scraped_spec)
view = ScrapedViewFeature(self.page, scraped_data)
out = view.generate_data()
expected = self.empty_view(scraped_data)
spec_content, mat_content = view.load_specification(spec.id)
section_content = view.load_section(section.id)
section_content["note"] = {"en": "new note"}
expected["features"]["links"]["sections"] = [str(section.id)]
expected["linked"]["maturities"] = [mat_content]
expected["linked"]["specifications"] = [spec_content]
expected["linked"]["sections"] = [section_content]
self.assertDataEqual(expected, out)
示例14: test_empty_scrape
# 需要导入模块: from mdn.scrape import ScrapedViewFeature [as 别名]
# 或者: from mdn.scrape.ScrapedViewFeature import generate_data [as 别名]
def test_empty_scrape(self):
scraped_data = self.empty_scrape()
view = ScrapedViewFeature(self.page, scraped_data)
out = view.generate_data()
expected = self.empty_view(scraped_data)
self.assertDataEqual(expected, out)