Пример #1
0
 def test_no_background_script(self):
   """Tests that a manifest with no background script errors."""
   with self.assertRaises(ValueError):
     chrome_app_manifest.verify({
       'manifest_version': 2,
       'app': {},
       'name': '',
       'version': '0.0.1',
     })
Пример #2
0
 def test_no_background_script(self):
     """Tests that a manifest with no background script errors."""
     with self.assertRaises(ValueError):
         chrome_app_manifest.verify({
             'manifest_version': 2,
             'app': {},
             'name': '',
             'version': '0.0.1',
         })
Пример #3
0
 def test_warnings_for_unconverted_members(self, mock_logging):
   """Tests that a manifest with unconvertible members triggers a warning."""
   chrome_app_manifest.verify({
     'manifest_version': 2,
     'app': {'background': ''},
     'name': '',
     'version': '0.0.1',
     'unconvertible': True
   })
   mock_logging.warning.assert_called_with(
     'Manifest member `%s` will not be converted.', 'unconvertible')
Пример #4
0
 def test_wrong_manifest_version(self, mock_logging):
   """Tests that a manifest with the wrong version number triggers a warning.
   """
   chrome_app_manifest.verify({
     'manifest_version': 1,
     'app': {'background': ''},
     'name': '',
     'version': '0.0.1',
   })
   mock_logging.warning.assert_called_with(
     'Chrome Apps must have manifest version 2, found manifest version %s.', 1)
Пример #5
0
 def test_warnings_for_unconverted_members(self, mock_logging):
     """Tests that a manifest with unconvertible members triggers a warning."""
     chrome_app_manifest.verify({
         'manifest_version': 2,
         'app': {
             'background': ''
         },
         'name': '',
         'version': '0.0.1',
         'unconvertible': True
     })
     mock_logging.warning.assert_called_with(
         'Manifest member `%s` will not be converted.', 'unconvertible')
Пример #6
0
 def test_no_warnings_for_convertible_members(self, mock_logging):
   """Tests that no warnings are triggered for convertible members."""
   convertible_members = {'short_name', 'default_locale', 'icons', 'author',
     'description'}
   for member in convertible_members:
     chrome_app_manifest.verify({
       'manifest_version': 2,
       'app': {'background': ''},
       'name': '',
       'version': '0.0.1',
       member: ''
     })
     self.assertFalse(mock_logging.warning.called)
Пример #7
0
 def test_wrong_manifest_version(self, mock_logging):
     """Tests that a manifest with the wrong version number triggers a warning.
 """
     chrome_app_manifest.verify({
         'manifest_version': 1,
         'app': {
             'background': ''
         },
         'name': '',
         'version': '0.0.1',
     })
     mock_logging.warning.assert_called_with(
         'Chrome Apps must have manifest version 2, found manifest version %s.',
         1)
Пример #8
0
 def test_no_warnings_for_convertible_members(self, mock_logging):
     """Tests that no warnings are triggered for convertible members."""
     convertible_members = {
         'short_name', 'default_locale', 'icons', 'author', 'description'
     }
     for member in convertible_members:
         chrome_app_manifest.verify({
             'manifest_version': 2,
             'app': {
                 'background': ''
             },
             'name': '',
             'version': '0.0.1',
             member: ''
         })
         self.assertFalse(mock_logging.warning.called)
Пример #9
0
 def test_minimum_requirements(self):
   """Tests that a manifest fulfilling the minimum requirements returns None.
   """
   self.assertIsNone(chrome_app_manifest.verify({
     'manifest_version': 2,
     'app': {'background': ''},
     'name': '',
     'version': '0.0.1',
   }))
Пример #10
0
 def test_minimum_requirements(self):
     """Tests that a manifest fulfilling the minimum requirements returns None.
 """
     self.assertIsNone(
         chrome_app_manifest.verify({
             'manifest_version': 2,
             'app': {
                 'background': ''
             },
             'name': '',
             'version': '0.0.1',
         }))
Пример #11
0
 def test_almost_empty(self, mock_logging):
   """Tests that a manifest with only one required member errors or triggers
   warnings (depending on the member remaining).
   """
   chrome_app_manifest.verify({'app': {'background': ''}})
   mock_logging.warning.assert_has_calls([
     mock.call('Chrome Apps must include a version.'),
     mock.call('Chrome Apps must include a name.'),
     mock.call('Chrome Apps must have manifest version 2.'),
   ], any_order=True)
   with self.assertRaises(ValueError):
     chrome_app_manifest.verify({'manifest_version': 2})
   with self.assertRaises(ValueError):
     chrome_app_manifest.verify({'app': {}})
   with self.assertRaises(ValueError):
     chrome_app_manifest.verify({'version': '0.0.1'})
Пример #12
0
 def test_almost_empty(self, mock_logging):
     """Tests that a manifest with only one required member errors or triggers
 warnings (depending on the member remaining).
 """
     chrome_app_manifest.verify({'app': {'background': ''}})
     mock_logging.warning.assert_has_calls([
         mock.call('Chrome Apps must include a version.'),
         mock.call('Chrome Apps must include a name.'),
         mock.call('Chrome Apps must have manifest version 2.'),
     ],
                                           any_order=True)
     with self.assertRaises(ValueError):
         chrome_app_manifest.verify({'manifest_version': 2})
     with self.assertRaises(ValueError):
         chrome_app_manifest.verify({'app': {}})
     with self.assertRaises(ValueError):
         chrome_app_manifest.verify({'version': '0.0.1'})
Пример #13
0
    def test_all_but_one(self, mock_logging):
        """Tests that a manifest with all but one required member errors or triggers
    a warning (depending on the member missing)."""
        chrome_app_manifest.verify({
            'app': {
                'background': ''
            },
            'name': '',
            'version': '0.0.1',
        })
        mock_logging.warning.assert_called_with(
            'Chrome Apps must have manifest version 2.')
        mock_logging.warning.reset_mock()

        chrome_app_manifest.verify({
            'manifest_version': 2,
            'app': {
                'background': ''
            },
            'version': '0.0.1',
        })
        mock_logging.warning.assert_called_with(
            'Chrome Apps must include a name.')
        mock_logging.warning.reset_mock()

        chrome_app_manifest.verify({
            'manifest_version': 2,
            'app': {
                'background': ''
            },
            'name': '',
        })
        mock_logging.warning.assert_called_with(
            'Chrome Apps must include a version.')

        with self.assertRaises(ValueError) as context:
            chrome_app_manifest.verify({
                'manifest_version': 2,
                'name': '',
                'version': '0.0.1',
            })
        self.assertEqual(context.exception.message,
                         'Chrome Apps must include a background script.')
Пример #14
0
  def test_all_but_one(self, mock_logging):
    """Tests that a manifest with all but one required member errors or triggers
    a warning (depending on the member missing)."""
    chrome_app_manifest.verify({
      'app': {'background': ''},
      'name': '',
      'version': '0.0.1',
    })
    mock_logging.warning.assert_called_with(
      'Chrome Apps must have manifest version 2.')
    mock_logging.warning.reset_mock()

    chrome_app_manifest.verify({
      'manifest_version': 2,
      'app': {'background': ''},
      'version': '0.0.1',
    })
    mock_logging.warning.assert_called_with(
      'Chrome Apps must include a name.')
    mock_logging.warning.reset_mock()

    chrome_app_manifest.verify({
      'manifest_version': 2,
      'app': {'background': ''},
      'name': '',
    })
    mock_logging.warning.assert_called_with(
      'Chrome Apps must include a version.')

    with self.assertRaises(ValueError) as context:
      chrome_app_manifest.verify({
        'manifest_version': 2,
        'name': '',
        'version': '0.0.1',
      })
    self.assertEqual(context.exception.message,
      'Chrome Apps must include a background script.')
Пример #15
0
 def test_empty(self, mock_logging):
     """Tests that an empty manifest errors."""
     with self.assertRaises(ValueError) as context:
         chrome_app_manifest.verify({})
     self.assertEqual(context.exception.message,
                      'Chrome Apps must include a background script.')
Пример #16
0
 def test_empty(self, mock_logging):
   """Tests that an empty manifest errors."""
   with self.assertRaises(ValueError) as context:
     chrome_app_manifest.verify({})
   self.assertEqual(context.exception.message,
     'Chrome Apps must include a background script.')