Ejemplo n.º 1
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["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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)