def test_info(fake_info, fake_find_slug): """ Test plugins.info. """ plugins.init(None, None) plugin = plugins.info('tha-server', 'This is the Name') assert plugin['everything'] == 42 fake_find_slug.assert_called_once_with('tha-server', 'This is the Name') fake_info.assert_called_once_with( 'tha-server', 'this.is-the_slug', fields='website,dbo_page,description,' + 'versions.type,' + 'versions.game_versions,' + 'versions.version,plugin_name,' + 'server,authors,categories,' + 'stage,slug')
def info(self): """ Display info about a plugin. """ query = self.args.plugins self.p_main('Finding `{}` on BukGet'.format(query)) plugin = backend.info(self.server, query) if plugin is None: self.p_sub('Could not find `{}`'.format(query)) return self.p_main('Found {}:'.format(plugin['plugin_name'])) self.p_blank() website = plugin['website'] if len(website) == 0: website = plugin['dbo_page'] authors = common.list_names(plugin['authors']) categories = common.list_names(plugin['categories']) stage = plugin['stage'] name = plugin['plugin_name'] desciption = plugin['description'].strip() self.p_sub('Name: {}', name) self.p_sub('Description: {}', desciption) self.p_sub('Authors: {}', authors) self.p_sub('Website: {}', website) self.p_sub('Categories: {}', categories) self.p_sub('Stage: {}', stage) self.p_blank() self.p_sub('Versions:') self.p_sub(' R - Release, B - Beta, A - Alpha') versions = plugin['versions'] # Sorting if self.args.size >= 0: versions = versions[:min(self.args.size, len(versions))] else: versions = versions[max(self.args.size, -len(versions)):] # Formatting max_len = max([len(v['version']) for v in versions]) frmt = '({{:1}}) {{:>{}}} - {{}}'.format(max_len) for version in versions: line = frmt.format(version['type'].upper()[0], version['version'], common.list_names(version['game_versions'])) self.p_sub(line) self.p_blank()
def test_info(fake_info, fake_find_slug): """ Test plugins.info. """ plugins.init(None, None) plugin = plugins.info("tha-server", "This is the Name") assert plugin["everything"] == 42 fake_find_slug.assert_called_once_with("tha-server", "This is the Name") fake_info.assert_called_once_with( "tha-server", "this.is-the_slug", fields="website,dbo_page,description," + "versions.type," + "versions.game_versions," + "versions.version,plugin_name," + "server,authors,categories," + "stage,slug", )
def test_info_plugin_not_found(fake_find_slug): """ Test plugins.info with a non-existing plugin. """ plugins.init(None, None) plugin = plugins.info('herp', 'derp') assert plugin is None
def test_info_plugin_not_found(fake_find_slug): """ Test plugins.info with a non-existing plugin. """ plugins.init(None, None) plugin = plugins.info("herp", "derp") assert plugin is None