def test_getPluginNameAndModuleFromStream_with_invalid_descriptions(self): plugin_desc_content = StringIO("""\ [Core] Name = Bla{0}Bli Module = SimplePlugin """.format(PLUGIN_NAME_FORBIDEN_STRING)) analyzer = PluginFileAnalyzerWithInfoFile("mouf", ("yapsy-plugin")) res = analyzer._extractCorePluginInfo("bla", plugin_desc_content) self.assertEqual((None, None), res) plugin_desc_content = StringIO("""\ [Core] Name = Simple Plugin """) analyzer = PluginFileAnalyzerWithInfoFile("mouf", ("yapsy-plugin")) res = analyzer._extractCorePluginInfo("bla", plugin_desc_content) self.assertEqual((None, None), res) plugin_desc_content = StringIO("""\ [Core] Module = Simple Plugin """) res = analyzer._extractCorePluginInfo("bla", plugin_desc_content) self.assertEqual((None, None), res) plugin_desc_content = StringIO("""\ [Mouf] Bla = Simple Plugin """) res = analyzer._extractCorePluginInfo("bla", plugin_desc_content) self.assertEqual((None, None), res)
def test_getPluginNameAndModuleFromStream_with_invalid_descriptions(self): plugin_desc_content = StringIO("""\ [Core] Name = Bla{0}Bli Module = SimplePlugin """.format(PLUGIN_NAME_FORBIDEN_STRING)) analyzer = PluginFileAnalyzerWithInfoFile("mouf", ("yapsy-plugin")) res = analyzer._extractCorePluginInfo("bla",plugin_desc_content) self.assertEqual((None, None), res) plugin_desc_content = StringIO("""\ [Core] Name = Simple Plugin """) analyzer = PluginFileAnalyzerWithInfoFile("mouf", ("yapsy-plugin")) res = analyzer._extractCorePluginInfo("bla",plugin_desc_content) self.assertEqual((None, None), res) plugin_desc_content = StringIO("""\ [Core] Module = Simple Plugin """) res = analyzer._extractCorePluginInfo("bla",plugin_desc_content) self.assertEqual((None, None), res) plugin_desc_content = StringIO("""\ [Mouf] Bla = Simple Plugin """) res = analyzer._extractCorePluginInfo("bla",plugin_desc_content) self.assertEqual((None, None), res)
def test__extractCorePluginInfo_with_builtin_str_filename(self): plugin_desc_content = builtin_str("simpleplugin.yapsy-plugin") analyzer = PluginFileAnalyzerWithInfoFile("mouf", ("yapsy-plugin")) infos, parser = analyzer._extractCorePluginInfo(self.plugin_directory, plugin_desc_content) self.assertEqual("Simple Plugin", infos["name"]) self.assertEqual(os.path.join(self.plugin_directory, "SimplePlugin"), infos["path"])
def test__extractCorePluginInfo_with_unicode_filename(self): """Note: this test is redundant with its 'builtin_str' counterpart on Python3 but not on Python2""" # Note: compat.py redefines str as unicode for Python2 plugin_desc_content = str("simpleplugin.yapsy-plugin") analyzer = PluginFileAnalyzerWithInfoFile("mouf", ("yapsy-plugin")) infos, parser = analyzer._extractCorePluginInfo(self.plugin_directory, plugin_desc_content) self.assertEqual("Simple Plugin", infos["name"]) self.assertEqual(os.path.join(self.plugin_directory, "SimplePlugin"), infos["path"])
def test__extractCorePluginInfo_with_minimal_description(self): plugin_desc_content = StringIO("""\ [Core] Name = Simple Plugin Module = SimplePlugin """) analyzer = PluginFileAnalyzerWithInfoFile("mouf", ("yapsy-plugin")) infos, parser = analyzer._extractCorePluginInfo( "bla", plugin_desc_content) self.assertEqual("Simple Plugin", infos["name"]) self.assertEqual(os.path.join("bla", "SimplePlugin"), infos["path"]) self.assertTrue(isinstance(parser, ConfigParser))
def test__extractCorePluginInfo_with_minimal_description(self): plugin_desc_content = StringIO("""\ [Core] Name = Simple Plugin Module = SimplePlugin """) analyzer = PluginFileAnalyzerWithInfoFile("mouf", ("yapsy-plugin")) infos, parser = analyzer._extractCorePluginInfo("bla",plugin_desc_content) self.assertEqual("Simple Plugin", infos["name"]) self.assertEqual(os.path.join("bla","SimplePlugin"), infos["path"]) self.assertTrue(isinstance(parser,ConfigParser))