tools/metrics/histograms/expand_owners_unittest.py
def testExpandOwnersWithFileDirectiveOWNERSFilePath(self, mock_dirmd_extract):
    """Checks that OWNERS files with file directives are expanded."""
    mock_dirmd_extract.return_value = None
    simple_absolute_path = _MakeOwnersFile('simple_OWNERS', self.temp_dir)

    with open(simple_absolute_path, 'w') as owners_file:
      owners_file.write('naz@chromium.org')

    file_directive_absolute_path = (
        _MakeOwnersFile('file_directive_OWNERS', self.temp_dir))
    file_directive_src_relative_path = (
        _GetSrcRelativePath(file_directive_absolute_path))

    directive = _GetFileDirective(simple_absolute_path)
    with open(file_directive_absolute_path, 'w') as owners_file:
      owners_file.write('\n'.join([
          'amy@chromium.org', directive, 'rae@chromium.org',
      ]))

    histograms = xml.dom.minidom.parseString("""
<histograms>

<histogram name="Caffeination" units="mg">
  <owner>joe@chromium.org</owner>
  <owner>{}</owner>
  <summary>I like coffee.</summary>
</histogram>

</histograms>
""".format(file_directive_src_relative_path))

    expected_histograms = xml.dom.minidom.parseString("""
<histograms>

<histogram name="Caffeination" units="mg">
  <owner>joe@chromium.org</owner>
  <owner>amy@chromium.org</owner>
  <owner>naz@chromium.org</owner>
  <owner>rae@chromium.org</owner>
  <summary>I like coffee.</summary>
</histogram>

</histograms>
""")

    expand_owners.ExpandHistogramsOWNERS(histograms)
    self.assertEqual(histograms.toxml(), expected_histograms.toxml())
Checks that OWNERS files with file directives are expanded.
Checks that OWNERS files with file directives are expanded.
Checks that OWNERS files with file directives are expanded .
def testExpandOwnersWithFileDirectiveOWNERSFilePath(self, mock_dirmd_extract):
    mock_dirmd_extract.return_value = None
    simple_absolute_path = _MakeOwnersFile('simple_OWNERS', self.temp_dir)
    with open(simple_absolute_path, 'w') as owners_file:
      owners_file.write('naz@chromium.org')
    file_directive_absolute_path = (
        _MakeOwnersFile('file_directive_OWNERS', self.temp_dir))
    file_directive_src_relative_path = (
        _GetSrcRelativePath(file_directive_absolute_path))
    directive = _GetFileDirective(simple_absolute_path)
    with open(file_directive_absolute_path, 'w') as owners_file:
      owners_file.write('\n'.join([
          'amy@chromium.org', directive, 'rae@chromium.org',
      ]))
    histograms = xml.dom.minidom.parseString("""
<histograms>
<histogram name="Caffeination" units="mg">
  <owner>joe@chromium.org</owner>
  <owner>{}</owner>
  <summary>I like coffee.</summary>
</histogram>
</histograms>
""".format(file_directive_src_relative_path))
    expected_histograms = xml.dom.minidom.parseString("""
<histograms>
<histogram name="Caffeination" units="mg">
  <owner>joe@chromium.org</owner>
  <owner>amy@chromium.org</owner>
  <owner>naz@chromium.org</owner>
  <owner>rae@chromium.org</owner>
  <summary>I like coffee.</summary>
</histogram>
</histograms>
""")
    expand_owners.ExpandHistogramsOWNERS(histograms)
    self.assertEqual(histograms.toxml(), expected_histograms.toxml())
def testExpandOwnersWithFileDirectiveOWNERSFilePath ( self , mock_dirmd_extract ) : mock_dirmd_extract . return_value = None simple_absolute_path = _MakeOwnersFile ( 'simple_OWNERS' , self . temp_dir ) with open ( simple_absolute_path , 'w' ) as owners_file : owners_file . write ( 'naz@chromium.org' ) file_directive_absolute_path = ( _MakeOwnersFile ( 'file_directive_OWNERS' , self . temp_dir ) ) file_directive_src_relative_path = ( _GetSrcRelativePath ( file_directive_absolute_path ) ) directive = _GetFileDirective ( simple_absolute_path ) with open ( file_directive_absolute_path , 'w' ) as owners_file : owners_file . write ( '\n' . join ( [ 'amy@chromium.org' , directive , 'rae@chromium.org' , ] ) ) histograms = xml . dom . minidom . parseString ( """
<histograms>

<histogram name="Caffeination" units="mg">
  <owner>joe@chromium.org</owner>
  <owner>{}</owner>
  <summary>I like coffee.</summary>
</histogram>

</histograms>
""" . format ( file_directive_src_relative_path ) ) expected_histograms = xml . dom . minidom . parseString ( """
<histograms>

<histogram name="Caffeination" units="mg">
  <owner>joe@chromium.org</owner>
  <owner>amy@chromium.org</owner>
  <owner>naz@chromium.org</owner>
  <owner>rae@chromium.org</owner>
  <summary>I like coffee.</summary>
</histogram>

</histograms>
""" ) expand_owners . ExpandHistogramsOWNERS ( histograms ) self . assertEqual ( histograms . toxml ( ) , expected_histograms . toxml ( ) )
Checks that OWNERS files with file directives are expanded.
Checks that OWNERS files with file directives are expanded .
"""Checks that OWNERS files with file directives are expanded."""
self
mock_dirmd_extract