def test_add_plugin_views_to_compare_view_missing_key(self): cr = CompareRoutes(AppMock(), None) plugin_views = [('plugin_1', b'<plugin view 1>'), ('plugin_2', b'<plugin view 2>')] compare_view = 'xxxxxyyyyy' result = cr._add_plugin_views_to_compare_view(compare_view, plugin_views) assert result == compare_view
def test_add_plugin_views_to_compare_view(): cr = CompareRoutes(AppMock(), None) plugin_views = [ ('plugin_1', b'<plugin view 1>'), ('plugin_2', b'<plugin view 2>') ] key = '{# individual plugin views #}' compare_view = 'xxxxx{}yyyyy'.format(key) key_index = compare_view.find(key) result = cr._add_plugin_views_to_compare_view(compare_view, plugin_views) for plugin, view in plugin_views: assert 'elif plugin == \'{}\''.format(plugin) in result assert view.decode() in result assert key_index + len(key) <= result.find(view.decode()) < result.find('yyyyy')