Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
bug 1216786 - Import empty notes as omitted
Browse files Browse the repository at this point in the history
Instead of importing empty notes as the English string "", import them
as no note, to reduce translation burden.
  • Loading branch information
jwhitlock committed Feb 25, 2016
1 parent 3c06922 commit f282111
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mdn/scrape.py
Expand Up @@ -381,6 +381,7 @@ def load_specification_row(self, spec_row):
# Load Specification Section
if spec_row['section.id']:
section_content = self.load_section(spec_row['section.id'])
# TODO: bug 1251252 - empty name, subpath is None
section_content['name']['en'] = spec_row['section.name']
section_content['subpath']['en'] = spec_row['section.subpath']
else:
Expand All @@ -389,7 +390,10 @@ def load_specification_row(self, spec_row):

# Load Reference
reference_content = self.load_or_new_reference(section_content['id'])
reference_content['note']['en'] = spec_row['section.note']
if spec_row['section.note']:
reference_content['note']['en'] = spec_row['section.note']
else:
reference_content['note'] = None
self.add_resource('references', reference_content)

def load_compat_table(self, table):
Expand Down
27 changes: 27 additions & 0 deletions mdn/tests/test_scrape.py
Expand Up @@ -596,6 +596,33 @@ def test_load_specification_row_new_resources(self):
expected['linked']['references'] = [reference_content]
self.assertDataEqual(expected, out)

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)

def test_load_specification_row_existing_resources(self):
reference = self.get_instance(
'Reference', ('web-css-background-size', 'background-size'))
Expand Down

0 comments on commit f282111

Please sign in to comment.