def test_validate__prefs_incorrect_type__exception_raised(
         self, valid_manifest):
     valid_manifest['preferences'] = [{'id': 'id', 'type': 'incorrect'}]
     manifest = ExtensionManifest(valid_manifest)
     with pytest.raises(ExtensionManifestError) as e:
         manifest.validate()
     assert e.value.error_name == ExtensionError.InvalidManifest.value
Beispiel #2
0
 def test_validate__prefs_empty_id__exception_raised(
         self, ext_dir, valid_manifest):
     valid_manifest['preferences'] = [{}]
     manifest = ExtensionManifest('test_extension', valid_manifest, ext_dir)
     with pytest.raises(ExtensionManifestError) as e:
         manifest.validate()
     assert e.value.error_name == ErrorName.InvalidManifestJson.value
Beispiel #3
0
    def test_get_preference(self, ext_dir):
        manifest_dict = {
            'preferences': [{
                'id': 'myid',
                'type': 'keyword',
                'default_value': 'mi',
                'name': "Mimimi",
                'icon': 'images/icon.png'
            }, {
                'id': 'newid',
                'type': 'input',
                'default_value': 'ni'
            }]
        }
        manifest = ExtensionManifest('test_extension', manifest_dict, ext_dir)
        assert manifest.get_preference('newid') == {
            'id': 'newid',
            'type': 'input',
            'default_value': 'ni',
        }

        assert manifest.get_preference('myid') == {
            'id': 'myid',
            'type': 'keyword',
            'default_value': 'mi',
            'name': 'Mimimi',
            'icon': 'images/icon.png'
        }
Beispiel #4
0
 def test_check_compatibility__manifest_version_12__exception_raised(
         self, ext_dir):
     manifest = ExtensionManifest('test_extension',
                                  {'required_api_version': '0'}, ext_dir)
     with pytest.raises(ExtensionManifestError) as e:
         manifest.check_compatibility()
     assert e.value.error_name == ErrorName.ExtensionCompatibilityError.value
 def test_check_compatibility__manifest_version_12__exception_raised(self):
     manifest = ExtensionManifest({
         "name": "Test",
         "required_api_version": "0"
     })
     with pytest.raises(ExtensionManifestError) as e:
         manifest.check_compatibility()
     assert e.value.error_name == ExtensionError.Incompatible.value
 def test_validate__raises_error_if_empty_default_value_for_keyword(
         self, valid_manifest):
     valid_manifest['preferences'] = [{
         'id': 'id',
         'type': 'keyword',
         'name': 'My Keyword'
     }]
     manifest = ExtensionManifest(valid_manifest)
     with pytest.raises(ExtensionManifestError) as e:
         manifest.validate()
     assert e.value.error_name == ExtensionError.InvalidManifest.value
Beispiel #7
0
 def test_validate__type_kw_empty_name__exception_raised(
         self, ext_dir, valid_manifest):
     valid_manifest['preferences'] = [{
         'id': 'id',
         'type': 'incorrect',
         'keyword': 'kw'
     }]
     manifest = ExtensionManifest('test_extension', valid_manifest, ext_dir)
     with pytest.raises(ExtensionManifestError) as e:
         manifest.validate()
     assert e.value.error_name == ErrorName.InvalidManifestJson.value
 def test_validate__doesnt_raise_if_empty_default_value_for_non_keyword(
         self, valid_manifest):
     valid_manifest['preferences'] = [
         {
             'id': 'id',
             'type': 'keyword',
             'name': 'My Keyword',
             'default_value': 'kw'
         },
         {
             'id': 'city',
             'type': 'input',
             'name': 'City'
         },
     ]
     manifest = ExtensionManifest(valid_manifest)
     manifest.validate()
Beispiel #9
0
 def test_get_option__option_exists__value_returned(self, ext_dir):
     manifest_dict = {'options': {'query_debounce': 0.5}}
     manifest = ExtensionManifest('test_extension', manifest_dict, ext_dir)
     assert manifest.get_option('query_debounce') == 0.5
 def test_validate__prefs_empty_id__exception_raised(self, valid_manifest):
     valid_manifest['preferences'] = [{}]
     manifest = ExtensionManifest(valid_manifest)
     with pytest.raises(ExtensionManifestError) as e:
         manifest.validate()
     assert e.value.error_name == ExtensionError.InvalidManifest.value
 def test_validate__valid_manifest__no_exceptions_raised(
         self, valid_manifest):
     manifest = ExtensionManifest(valid_manifest)
     manifest.validate()
 def test_validate__name_empty__exception_raised(self):
     manifest = ExtensionManifest({"required_api_version": "1"})
     with pytest.raises(ExtensionManifestError) as e:
         manifest.validate()
     assert e.value.error_name == ExtensionError.InvalidManifest.value
 def test_get_option__option_doesnt_exist__default_returned(self):
     manifest = ExtensionManifest({"options": {}})
     assert manifest.get_option('query_debounce', 0.4) == 0.4
 def test_get_option__option_exists__value_returned(self):
     manifest = ExtensionManifest({"options": {"query_debounce": 0.5}})
     assert manifest.get_option("query_debounce") == 0.5
 def test_check_compatibility__required_api_version_1__no_exceptions(self):
     manifest = ExtensionManifest({
         "name": "Test",
         "required_api_version": "2"
     })
     manifest.check_compatibility()
Beispiel #16
0
 def test_check_compatibility__required_api_version_1__no_exceptions(
         self, ext_dir):
     manifest = ExtensionManifest('test_extension',
                                  {'required_api_version': '2'}, ext_dir)
     manifest.check_compatibility()
Beispiel #17
0
 def test_get_option__option_doesnt_exist__default_returned(self, ext_dir):
     manifest_dict = {'options': {}}
     manifest = ExtensionManifest('test_extension', manifest_dict, ext_dir)
     assert manifest.get_option('query_debounce', 0.4) == 0.4
Beispiel #18
0
 def test_validate__valid_manifest__no_exceptions_raised(
         self, ext_dir, valid_manifest):
     manifest = ExtensionManifest('test_extension', valid_manifest, ext_dir)
     manifest.validate()
Beispiel #19
0
 def test_validate__name_empty__exception_raised(self, ext_dir):
     manifest = ExtensionManifest('test_extension',
                                  {'required_api_version': '1'}, ext_dir)
     with pytest.raises(ExtensionManifestError) as e:
         manifest.validate()
     assert e.value.error_name == ErrorName.InvalidManifestJson.value
Beispiel #20
0
 def test_refresh__name__is_reloaded(self, ext_dir):
     manifest = ExtensionManifest('test_extension', {'name': 'Old'},
                                  ext_dir)
     assert manifest.get_name() == 'Old'
     manifest.refresh()
     assert manifest.get_name() == "Test Extension"