예제 #1
0
 def test_new_support_with_note(self):
     support_entry = {
         'id': '_support',
         'feature': '_feature',
         'version': '_version',
         'support': 'yes',
         'footnote': 'The Footnote'
     }
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     support_content = view.new_support(support_entry)
     expected = {
         'id': '_support',
         'support': 'yes',
         'note': {
             'en': 'The Footnote'
         },
         'prefix': None,
         'prefix_mandatory': False,
         'protected': False,
         'requires_config': None,
         'default_config': None,
         'alternate_name': None,
         'alternate_mandatory': False,
         'links': {
             'feature': '_feature',
             'version': '_version'
         }
     }
     self.assertDataEqual(expected, support_content)
예제 #2
0
 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'])
예제 #3
0
 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)
예제 #4
0
 def test_new_section(self):
     spec_row = {
         'section.note': 'section note',
         'section.subpath': '#section',
         'section.name': 'section',
         'specification.mdn_key': 'CSS3 UI',
         'section.id': None,
         'specification.id': None
     }
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     section_content = view.new_section(spec_row, '_CSS3_UI')
     expected = {
         'id': '__CSS3_UI_#section',
         'name': {
             'en': 'section'
         },
         'number': None,
         'subpath': {
             'en': '#section'
         },
         'links': {
             'specification': '_CSS3_UI'
         }
     }
     self.assertDataEqual(expected, section_content)
예제 #5
0
 def test_new_specification(self):
     spec_row = {
         'section.note': 'section note',
         'section.subpath': '#section',
         'section.name': 'section',
         'specification.mdn_key': 'CSS3 UI',
         'section.id': None,
         'specification.id': None
     }
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     spec_content, mat_content = view.new_specification(spec_row)
     expected_spec = {
         'id': '_CSS3 UI',
         'mdn_key': 'CSS3 UI',
         'links': {
             'maturity': '_unknown'
         }
     }
     self.assertDataEqual(expected_spec, spec_content)
     expected_mat = {
         'id': '_unknown',
         'slug': '',
         'name': {
             'en': 'Unknown'
         },
         'links': {
             'specifications': []
         }
     }
     self.assertDataEqual(expected_mat, mat_content)
예제 #6
0
 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)
예제 #7
0
 def test_new_feature_canonical(self):
     feature_entry = {
         'id': '_feature',
         'name': 'cover',
         'canonical': True,
         'slug': 'web-css-background-size_cover'
     }
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.new_feature(feature_entry)
     expected = {
         'id': '_feature',
         'name': 'cover',
         'slug': 'web-css-background-size_cover',
         'mdn_uri': None,
         'obsolete': False,
         'stable': True,
         'standardized': True,
         'experimental': False,
         'links': {
             'children': [],
             'parent': str(self.feature.id),
             'references': [],
             'supports': []
         }
     }
     self.assertDataEqual(expected, feature_content)
예제 #8
0
 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)
예제 #9
0
 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'])
예제 #10
0
 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])
예제 #11
0
 def test_load_browser(self):
     browser = self.get_instance('Browser', 'firefox_desktop')
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     browser_content = view.load_browser(browser.id)
     expected = {
         'id': str(browser.id), 'name': {'en': 'Firefox for Desktop'},
         'note': None, 'slug': browser.slug}
     self.assertDataEqual(expected, browser_content)
예제 #12
0
 def test_load_section(self):
     section = self.get_instance('Section', 'background-size')
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     section_content = view.load_section(section.id)
     expected = {
         'id': str(section.id), 'name': section.name,
         'number': None, 'subpath': section.subpath,
         'links': {'specification': str(section.specification.id)}}
     self.assertDataEqual(expected, section_content)
예제 #13
0
 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)
예제 #14
0
 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)
예제 #15
0
 def test_new_nightly_version(self):
     version_entry = {
         'id': '_version', 'browser': '_browser', 'version': 'nightly'}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     version_content = view.new_version(version_entry)
     expected = {
         'id': '_version', 'version': 'nightly', 'status': 'future',
         'note': None, 'release_day': None, 'retirement_day': None,
         'release_notes_uri': None,
         'links': {'browser': '_browser'}}
     self.assertDataEqual(expected, version_content)
예제 #16
0
 def test_load_browser(self):
     browser = self.get_instance('Browser', 'firefox_desktop')
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     browser_content = view.load_browser(browser.id)
     expected = {
         'id': str(browser.id),
         'name': {
             'en': 'Firefox for Desktop'
         },
         'note': None,
         'slug': browser.slug
     }
     self.assertDataEqual(expected, browser_content)
예제 #17
0
 def test_load_section(self):
     section = self.get_instance("Section", "background-size")
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     section_content = view.load_section(section.id)
     expected = {
         "id": str(section.id),
         "name": section.name,
         "note": {},
         "number": None,
         "subpath": section.subpath,
         "links": {"specification": str(section.specification.id)},
     }
     self.assertDataEqual(expected, section_content)
예제 #18
0
 def test_new_support_with_note(self):
     support_entry = {
         'id': '_support', 'feature': '_feature', 'version': '_version',
         'support': 'yes', 'footnote': 'The Footnote'}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     support_content = view.new_support(support_entry)
     expected = {
         'id': '_support', 'support': 'yes', 'note': {'en': 'The Footnote'},
         'prefix': None, 'prefix_mandatory': False, 'protected': False,
         'requires_config': None, 'default_config': None,
         'alternate_name': None, 'alternate_mandatory': False,
         'links': {'feature': '_feature', 'version': '_version'}}
     self.assertDataEqual(expected, support_content)
예제 #19
0
 def test_load_support(self):
     version = self.get_instance('Version', ('firefox_desktop', '1.0'))
     feature = self.get_instance(
         'Feature', 'web-css-background-size-contain_and_cover')
     support = self.create(Support, version=version, feature=feature)
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     support_content = view.load_support(support.id)
     expected = {
         'id': str(support.id), 'support': 'yes', 'note': None,
         'prefix': None, 'prefix_mandatory': False, 'protected': False,
         'requires_config': None, 'default_config': None,
         'alternate_name': None, 'alternate_mandatory': False,
         'links': {'feature': str(feature.id), 'version': str(version.id)}}
     self.assertDataEqual(expected, support_content)
예제 #20
0
 def test_load_section(self):
     section = self.get_instance('Section', 'background-size')
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     section_content = view.load_section(section.id)
     expected = {
         'id': str(section.id),
         'name': section.name,
         'number': None,
         'subpath': section.subpath,
         'links': {
             'specification': str(section.specification.id)
         }
     }
     self.assertDataEqual(expected, section_content)
예제 #21
0
 def test_load_specification(self):
     spec = self.get_instance('Specification', 'css3_backgrounds')
     maturity = spec.maturity
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     spec_content, mat_content = view.load_specification(spec.id)
     expected_spec = {
         'id': str(spec.id), 'slug': spec.slug, 'mdn_key': spec.mdn_key,
         'uri': spec.uri, 'name': spec.name,
         'links': {'maturity': str(maturity.id)}}
     self.assertDataEqual(expected_spec, spec_content)
     expected_mat = {
         'id': str(maturity.id), 'slug': maturity.slug,
         'name': maturity.name}
     self.assertDataEqual(expected_mat, mat_content)
예제 #22
0
 def test_load_feature_canonical_name(self):
     feature = self.create(
         Feature, slug='web-css-background-size_list-item',
         name={'zxx': 'list-item'}, parent=self.feature)
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.load_feature(feature.id)
     expected = {
         'id': str(feature.id), 'name': 'list-item',
         'slug': feature.slug, 'mdn_uri': None, 'obsolete': False,
         'stable': True, 'standardized': True, 'experimental': False,
         'links': {
             'children': [], 'parent': str(self.feature.id),
             'references': [], 'supports': []}}
     self.assertDataEqual(expected, feature_content)
예제 #23
0
 def test_load_feature(self):
     feature = self.get_instance(
         'Feature', 'web-css-background-size-contain_and_cover')
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.load_feature(feature.id)
     expected = {
         'id': str(feature.id),
         'name': {'en': '<code>contain</code> and <code>cover</code>'},
         'slug': feature.slug, 'mdn_uri': None, 'obsolete': False,
         'stable': True, 'standardized': True, 'experimental': False,
         'links': {
             'children': [], 'parent': str(self.feature.id),
             'references': [], 'supports': []}}
     self.assertDataEqual(expected, feature_content)
예제 #24
0
 def test_new_specification(self):
     spec_row = {
         "section.note": "section note",
         "section.subpath": "#section",
         "section.name": "section",
         "specification.mdn_key": "CSS3 UI",
         "section.id": None,
         "specification.id": None,
     }
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     spec_content, mat_content = view.new_specification(spec_row)
     expected_spec = {"id": "_CSS3 UI", "mdn_key": "CSS3 UI", "links": {"maturity": "_unknown", "sections": []}}
     self.assertDataEqual(expected_spec, spec_content)
     expected_mat = {"id": "_unknown", "slug": "", "name": {"en": "Unknown"}, "links": {"specifications": []}}
     self.assertDataEqual(expected_mat, mat_content)
예제 #25
0
 def test_new_nightly_version(self):
     version_entry = {"id": "_version", "browser": "_browser", "version": "nightly"}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     version_content = view.new_version(version_entry)
     expected = {
         "id": "_version",
         "version": "nightly",
         "status": "future",
         "note": None,
         "release_day": None,
         "retirement_day": None,
         "release_notes_uri": None,
         "links": {"browser": "_browser"},
     }
     self.assertDataEqual(expected, version_content)
예제 #26
0
 def test_new_section(self):
     spec_row = {
         'section.note': 'section note',
         'section.subpath': '#section',
         'section.name': 'section',
         'specification.mdn_key': 'CSS3 UI',
         'section.id': None,
         'specification.id': None}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     section_content = view.new_section(spec_row, '_CSS3_UI')
     expected = {
         'id': '__CSS3_UI_#section', 'name': {'en': 'section'},
         'number': None, 'subpath': {'en': '#section'},
         'links': {'specification': '_CSS3_UI'}}
     self.assertDataEqual(expected, section_content)
예제 #27
0
 def test_new_feature_canonical(self):
     feature_entry = {
         'id': '_feature', 'name': 'cover', 'canonical': True,
         'slug': 'web-css-background-size_cover'}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.new_feature(feature_entry)
     expected = {
         'id': '_feature', 'name': 'cover',
         'slug': 'web-css-background-size_cover',
         'mdn_uri': None, 'obsolete': False, 'stable': True,
         'standardized': True, 'experimental': False,
         'links': {
             'children': [], 'parent': str(self.feature.id),
             'references': [], 'supports': []}}
     self.assertDataEqual(expected, feature_content)
예제 #28
0
 def test_load_feature(self):
     feature = self.get_instance("Feature", "web-css-background-size-contain_and_cover")
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.load_feature(feature.id)
     expected = {
         "id": str(feature.id),
         "name": {"en": "<code>contain</code> and <code>cover</code>"},
         "slug": feature.slug,
         "mdn_uri": None,
         "obsolete": False,
         "stable": True,
         "standardized": True,
         "experimental": False,
         "links": {"children": [], "parent": str(self.feature.id), "sections": [], "supports": []},
     }
     self.assertDataEqual(expected, feature_content)
예제 #29
0
 def test_new_feature_canonical(self):
     feature_entry = {"id": "_feature", "name": "cover", "canonical": True, "slug": "web-css-background-size_cover"}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.new_feature(feature_entry)
     expected = {
         "id": "_feature",
         "name": "cover",
         "slug": "web-css-background-size_cover",
         "mdn_uri": None,
         "obsolete": False,
         "stable": True,
         "standardized": True,
         "experimental": False,
         "links": {"children": [], "parent": str(self.feature.id), "sections": [], "supports": []},
     }
     self.assertDataEqual(expected, feature_content)
예제 #30
0
 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)
예제 #31
0
 def test_load_specification(self):
     spec = self.get_instance("Specification", "css3_backgrounds")
     maturity = spec.maturity
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     spec_content, mat_content = view.load_specification(spec.id)
     expected_spec = {
         "id": str(spec.id),
         "slug": spec.slug,
         "mdn_key": spec.mdn_key,
         "uri": spec.uri,
         "name": spec.name,
         "links": {"maturity": str(maturity.id), "sections": []},
     }
     self.assertDataEqual(expected_spec, spec_content)
     expected_mat = {"id": str(maturity.id), "slug": maturity.slug, "name": maturity.name}
     self.assertDataEqual(expected_mat, mat_content)
예제 #32
0
 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)
예제 #33
0
 def test_new_support(self):
     support_entry = {"id": "_support", "feature": "_feature", "version": "_version", "support": "yes"}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     support_content = view.new_support(support_entry)
     expected = {
         "id": "_support",
         "support": "yes",
         "note": None,
         "prefix": None,
         "prefix_mandatory": False,
         "protected": False,
         "requires_config": None,
         "default_config": None,
         "alternate_name": None,
         "alternate_mandatory": False,
         "links": {"feature": "_feature", "version": "_version"},
     }
     self.assertDataEqual(expected, support_content)
예제 #34
0
 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)
예제 #35
0
 def test_new_specification(self):
     spec_row = {
         'section.note': 'section note',
         'section.subpath': '#section',
         'section.name': 'section',
         'specification.mdn_key': 'CSS3 UI',
         'section.id': None,
         'specification.id': None}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     spec_content, mat_content = view.new_specification(spec_row)
     expected_spec = {
         'id': '_CSS3 UI', 'mdn_key': 'CSS3 UI',
         'links': {'maturity': '_unknown'}}
     self.assertDataEqual(expected_spec, spec_content)
     expected_mat = {
         'id': '_unknown', 'slug': '', 'name': {'en': 'Unknown'},
         'links': {'specifications': []}}
     self.assertDataEqual(expected_mat, mat_content)
예제 #36
0
 def test_load_feature_canonical_name(self):
     feature = self.create(
         Feature, slug="web-css-background-size_list-item", name={"zxx": "list-item"}, parent=self.feature
     )
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.load_feature(feature.id)
     expected = {
         "id": str(feature.id),
         "name": "list-item",
         "slug": feature.slug,
         "mdn_uri": None,
         "obsolete": False,
         "stable": True,
         "standardized": True,
         "experimental": False,
         "links": {"children": [], "parent": str(self.feature.id), "sections": [], "supports": []},
     }
     self.assertDataEqual(expected, feature_content)
예제 #37
0
 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'])
예제 #38
0
 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)
예제 #39
0
 def test_load_support(self):
     version = self.get_instance("Version", ("firefox_desktop", "1.0"))
     feature = self.get_instance("Feature", "web-css-background-size-contain_and_cover")
     support = self.create(Support, version=version, feature=feature)
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     support_content = view.load_support(support.id)
     expected = {
         "id": str(support.id),
         "support": "yes",
         "note": None,
         "prefix": None,
         "prefix_mandatory": False,
         "protected": False,
         "requires_config": None,
         "default_config": None,
         "alternate_name": None,
         "alternate_mandatory": False,
         "links": {"feature": str(feature.id), "version": str(version.id)},
     }
     self.assertDataEqual(expected, support_content)
예제 #40
0
 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()
     expected = self.empty_view(scraped_data)
     support_content = view.new_support(scraped_table['supports'][0])
     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(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]
     })
     expected['meta']['compat_table']['notes'][support_id] = 1
     self.assertDataEqual(expected, out)
예제 #41
0
 def test_new_nightly_version(self):
     version_entry = {
         'id': '_version',
         'browser': '_browser',
         'version': 'nightly'
     }
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     version_content = view.new_version(version_entry)
     expected = {
         'id': '_version',
         'version': 'nightly',
         'status': 'future',
         'note': None,
         'release_day': None,
         'retirement_day': None,
         'release_notes_uri': None,
         'links': {
             'browser': '_browser'
         }
     }
     self.assertDataEqual(expected, version_content)
예제 #42
0
 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)
예제 #43
0
 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])
예제 #44
0
 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)
예제 #45
0
 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)
예제 #46
0
 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)
예제 #47
0
 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)
예제 #48
0
 def test_load_specification(self):
     spec = self.get_instance('Specification', 'css3_backgrounds')
     maturity = spec.maturity
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     spec_content, mat_content = view.load_specification(spec.id)
     expected_spec = {
         'id': str(spec.id),
         'slug': spec.slug,
         'mdn_key': spec.mdn_key,
         'uri': spec.uri,
         'name': spec.name,
         'links': {
             'maturity': str(maturity.id)
         }
     }
     self.assertDataEqual(expected_spec, spec_content)
     expected_mat = {
         'id': str(maturity.id),
         'slug': maturity.slug,
         'name': maturity.name
     }
     self.assertDataEqual(expected_mat, mat_content)
예제 #49
0
 def test_load_feature_canonical_name(self):
     feature = self.create(Feature,
                           slug='web-css-background-size_list-item',
                           name={'zxx': 'list-item'},
                           parent=self.feature)
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.load_feature(feature.id)
     expected = {
         'id': str(feature.id),
         'name': 'list-item',
         'slug': feature.slug,
         'mdn_uri': None,
         'obsolete': False,
         'stable': True,
         'standardized': True,
         'experimental': False,
         'links': {
             'children': [],
             'parent': str(self.feature.id),
             'references': [],
             'supports': []
         }
     }
     self.assertDataEqual(expected, feature_content)
예제 #50
0
 def test_load_support(self):
     version = self.get_instance('Version', ('firefox_desktop', '1.0'))
     feature = self.get_instance(
         'Feature', 'web-css-background-size-contain_and_cover')
     support = self.create(Support, version=version, feature=feature)
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     support_content = view.load_support(support.id)
     expected = {
         'id': str(support.id),
         'support': 'yes',
         'note': None,
         'prefix': None,
         'prefix_mandatory': False,
         'protected': False,
         'requires_config': None,
         'default_config': None,
         'alternate_name': None,
         'alternate_mandatory': False,
         'links': {
             'feature': str(feature.id),
             'version': str(version.id)
         }
     }
     self.assertDataEqual(expected, support_content)
예제 #51
0
 def test_load_feature(self):
     feature = self.get_instance(
         'Feature', 'web-css-background-size-contain_and_cover')
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.load_feature(feature.id)
     expected = {
         'id': str(feature.id),
         'name': {
             'en': '<code>contain</code> and <code>cover</code>'
         },
         'slug': feature.slug,
         'mdn_uri': None,
         'obsolete': False,
         'stable': True,
         'standardized': True,
         'experimental': False,
         'links': {
             'children': [],
             'parent': str(self.feature.id),
             'references': [],
             'supports': []
         }
     }
     self.assertDataEqual(expected, feature_content)
예제 #52
0
 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'])
예제 #53
0
 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)