コード例 #1
0
ファイル: test_scrape.py プロジェクト: yyinhai/browsercompat
 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
ファイル: test_scrape.py プロジェクト: renoirb/browsercompat
 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)
コード例 #3
0
ファイル: test_scrape.py プロジェクト: renoirb/browsercompat
 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)
コード例 #4
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)
コード例 #5
0
ファイル: test_scrape.py プロジェクト: yyinhai/browsercompat
 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)
コード例 #6
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)
コード例 #7
0
ファイル: test_scrape.py プロジェクト: renoirb/browsercompat
 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)
コード例 #8
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)