prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: <|fim_middle|> def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: <|fim_middle|> else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: <|fim_middle|> else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
return
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove <|fim_middle|> def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
unregister_old(bl_id)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: <|fim_middle|> print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): <|fim_middle|> print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: <|fim_middle|> print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: <|fim_middle|> print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) <|fim_middle|> def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
mod.unregister() del imported_mods[bl_id]
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def <|fim_middle|>(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
is_old
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def <|fim_middle|>(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
scan_for_old
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def <|fim_middle|>(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
mark_old
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def <|fim_middle|>(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
reload_old
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def <|fim_middle|>(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
load_old
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def <|fim_middle|>(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
register_old
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def <|fim_middle|>(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def unregister(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
unregister_old
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### old_bl_idnames = { 'CentersPolsNode' : "centers", # 'BakeryNode' : "bakery", 'CircleNode' : "circle", 'ListItemNode' : "list_item", 'GenRangeNode' : "range", 'GenSeriesNode' : "series", # 'Test1Node' : "test", # 'Test2Node' : "test", # 'ToolsNode' : "tools", 'SvReRouteNode': "reroute", 'VoronoiNode': "voronoi", 'ViewerNode': "viewer", 'EvalKnievalNode': "eval_knieval", 'FormulaNode': 'formula', } # we should add some functions to load things there import importlib import inspect import traceback import bpy from sverchok.node_tree import SverchCustomTreeNode imported_mods = {} def is_old(node_info): ''' Check if node or node.bl_idname is among the old nodes ''' if isinstance(node_info, str): # assumes bl_idname return node_info in old_bl_idnames elif isinstance(node_info, bpy.types.Node): return node_info.bl_idname in old_bl_idnames else: return False def scan_for_old(ng): nodes = [n for n in ng.nodes if n.bl_idname in old_bl_idnames] for node in nodes: mark_old(node) def mark_old(node): if node.parent and node.parent.label == "Deprecated node!": return ng = node.id_data frame = ng.nodes.new("NodeFrame") if node.parent: frame.parent = node.parent node.parent = frame frame.label = "Deprecated node!" frame.use_custom_color = True frame.color = (.8, 0, 0) frame.shrink = True def reload_old(ng=False): if ng: bl_idnames = {n.bl_idname for n in ng.nodes if n.bl_idname in old_bl_idnames} for bl_id in bl_idnames: mod = register_old(bl_id) if mod: importlib.reload(mod) else: print("Couldn't reload {}".format(bl_id)) else: for ng in bpy.data.node_groups: reload_old(ng) #if ng.bl_idname in { 'SverchCustomTreeType', 'SverchGroupTreeType'}: # reload_old(ng) def load_old(ng): """ This approach didn't work, bl_idname of undefined node isn't as I expected bl_idnames = {n.bl_idname for n in ng.nodes} old_bl_ids = bl_idnames.intersection(old_bl_idnames) if old_bl_ids: """ not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) if not_reged_nodes: for bl_id in old_bl_idnames: register_old(bl_id) nodes = [n for n in ng.nodes if n.bl_idname == bl_id] if nodes: for node in nodes: mark_old(node) not_reged_nodes = list(n for n in ng.nodes if not n.is_registered_node_type()) node_count = len(not_reged_nodes) print("Loaded {}. {} nodes are left unregisted.".format(bl_id, node_count)) if node_count == 0: return else: # didn't help remove unregister_old(bl_id) def register_old(bl_id): if bl_id in old_bl_idnames: mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__) res = inspect.getmembers(mod) for name, cls in res: if inspect.isclass(cls): if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id: if bl_id not in imported_mods: try: mod.register() except: traceback.print_exc() imported_mods[bl_id] = mod return mod print("Cannot find {} among old nodes".format(bl_id)) return None def unregister_old(bl_id): global imported_mods mod = imported_mods.get(bl_id) if mod: #print("Unloaded old node type {}".format(bl_id)) mod.unregister() del imported_mods[bl_id] def <|fim_middle|>(): global imported_mods print(imported_mods) for mod in imported_mods.values(): mod.unregister() imported_mods = {} <|fim▁end|>
unregister
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer')))<|fim▁hole|> print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main()<|fim▁end|>
print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO')))
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): <|fim_middle|> class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
o = option.Option(**{'handle': t, 'type': t}) o.validate() return o
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): <|fim_middle|> if __name__ == "__main__": unittest.main() <|fim▁end|>
@classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc)
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): <|fim_middle|> def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): <|fim_middle|> def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta')))
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): <|fim_middle|> def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def))
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): <|fim_middle|> def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1])
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): <|fim_middle|> # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r))
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): <|fim_middle|> if __name__ == "__main__": unittest.main() <|fim▁end|>
st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc)
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): <|fim_middle|> cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
os.remove(db)
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": <|fim_middle|> <|fim▁end|>
unittest.main()
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def <|fim_middle|>(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
go
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def <|fim_middle|>(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
setUpClass
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def <|fim_middle|>(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
test_get_typed_cols
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def <|fim_middle|>(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
test_get_insert_cmd
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def <|fim_middle|>(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
test_column_definition
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def <|fim_middle|>(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def test_tables(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
test_write_desc
<|file_name|>test_sqlstore.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python # -*- coding: utf-8 -*- import unittest import os from misura.canon import option from misura.canon.option import get_typed_cols, get_insert_cmd, base_col_def, print_tree import sqlite3 from misura.canon.tests import testdir db = testdir + 'storage/tmpdb' c1 = testdir + 'storage/Conf.csv' def go(t): o = option.Option(**{'handle': t, 'type': t}) o.validate() return o class SqlStore(unittest.TestCase): @classmethod def setUpClass(cls): if os.path.exists(db): os.remove(db) cls.conn = sqlite3.connect(db, detect_types=sqlite3.PARSE_DECLTYPES) st0 = option.CsvStore(kid='/base/') st0.merge_file(c1) st0.validate() cls.desc = st0.desc def test_get_typed_cols(self): print(get_typed_cols(go('Integer'))) print(get_typed_cols(go('String'))) print(get_typed_cols(go('Point'))) print(get_typed_cols(go('Role'))) print(get_typed_cols(go('RoleIO'))) print(get_typed_cols(go('Log'))) print(get_typed_cols(go('Meta'))) def test_get_insert_cmd(self): print(get_insert_cmd(go('Integer'), base_col_def)) print(get_insert_cmd(go('String'), base_col_def)) print(get_insert_cmd(go('Point'), base_col_def)) print(get_insert_cmd(go('Role'), base_col_def)) print(get_insert_cmd(go('RoleIO'), base_col_def)) print(get_insert_cmd(go('Log'), base_col_def)) print(get_insert_cmd(go('Meta'), base_col_def)) def test_column_definition(self): s = option.SqlStore() print(s.column_definition(go('Integer'))[1]) print(s.column_definition(go('String'))[1]) print(s.column_definition(go('Point'))[1]) print(s.column_definition(go('Role'))[1]) print(s.column_definition(go('RoleIO'))[1]) print(s.column_definition(go('Log'))[1]) print(s.column_definition(go('Meta'))[1]) def test_write_desc(self): s = option.SqlStore() s.cursor = self.conn.cursor() s.write_desc(self.desc) print('READING') r = s.read_tree() print(r) print('print(tree\n', print_tree(r)) print('WRITING AGAIN') s.write_tree(r) print("READING AGAIN") r = s.read_tree() print(r) print('print(tree2\n', print_tree(r)) # @unittest.skip('') def <|fim_middle|>(self): st0 = option.CsvStore(kid='ciao') st0.merge_file(c1) st = option.SqlStore(kid='ciao') st.desc = st0.desc k0 = set(st.desc.keys()) cursor = self.conn.cursor() st.write_table(cursor, 'conf1') self.conn.commit() cursor.execute('select handle from conf1') r = cursor.fetchall() k1 = set([eval(k[0]) for k in r]) self.assertEqual(k0, k1) st2 = option.SqlStore(kid='ciao') st2.read_table(cursor, 'conf1') self.assertEqual(st.desc, st2.desc) if __name__ == "__main__": unittest.main() <|fim▁end|>
test_tables
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan()<|fim▁hole|> task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed')<|fim▁end|>
task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks')
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): <|fim_middle|> @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all()
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): <|fim_middle|> @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop()
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): <|fim_middle|> @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
""" Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile')
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): <|fim_middle|> def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
""" Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance()
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> <|fim_middle|> @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr)
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): <|fim_middle|> @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
""" Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})')
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): <|fim_middle|> <|fim▁end|>
""" Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed')
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: <|fim_middle|> @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
return table.read().get(attr)
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: <|fim_middle|> else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
random_image_instance.assign_policy_profiles('OpenSCAP profile')
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: <|fim_middle|> random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
random_image_instance.unassign_policy_profiles('OpenSCAP profile')
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): <|fim_middle|> provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
continue
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: <|fim_middle|> value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: <|fim_middle|> else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
random_image_instance.assign_policy_profiles('OpenSCAP profile')
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: <|fim_middle|> original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
random_image_instance.unassign_policy_profiles('OpenSCAP profile')
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def <|fim_middle|>(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
delete_all_container_tasks
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def <|fim_middle|>(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
random_image_instance
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def <|fim_middle|>(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
test_manage_policies_navigation
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def <|fim_middle|>(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
test_check_compliance
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def <|fim_middle|>(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
get_table_attr
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def <|fim_middle|>(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis_api(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
test_containers_smartstate_analysis
<|file_name|>test_containers_smartstate_analysis.py<|end_file_name|><|fim▁begin|>import random from collections import namedtuple import dateparser import pytest from cfme import test_requirements from cfme.containers.image import Image from cfme.containers.provider import ContainersProvider from cfme.containers.provider import ContainersTestItem from cfme.utils.appliance.implementations.ui import navigate_to from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.meta(server_roles='+smartproxy'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(1), pytest.mark.provider([ContainersProvider], scope='function'), test_requirements.containers ] AttributeToVerify = namedtuple('AttributeToVerify', ['table', 'attr', 'verifier']) TESTED_ATTRIBUTES__openscap_off = ( AttributeToVerify('configuration', 'OpenSCAP Results', bool), AttributeToVerify('configuration', 'OpenSCAP HTML', lambda val: val == 'Available'), AttributeToVerify('configuration', 'Last scan', dateparser.parse) ) TESTED_ATTRIBUTES__openscap_on = TESTED_ATTRIBUTES__openscap_off + ( AttributeToVerify('compliance', 'Status', lambda val: val.lower() != 'never verified'), AttributeToVerify('compliance', 'History', lambda val: val == 'Available') ) TEST_ITEMS = ( ContainersTestItem(Image, 'openscap_off', is_openscap=False, tested_attr=TESTED_ATTRIBUTES__openscap_off), ContainersTestItem(Image, 'openscap_on', is_openscap=True, tested_attr=TESTED_ATTRIBUTES__openscap_on) ) NUM_SELECTED_IMAGES = 1 @pytest.fixture(scope='function') def delete_all_container_tasks(appliance): col = appliance.collections.tasks.filter({'tab': 'AllTasks'}) col.delete_all() @pytest.fixture(scope='function') def random_image_instance(appliance): collection = appliance.collections.container_images # add filter for select only active(not archived) images from redHat registry filter_image_collection = collection.filter({'active': True, 'redhat_registry': True}) return random.sample(filter_image_collection.all(), NUM_SELECTED_IMAGES).pop() @pytest.mark.polarion('10030') def test_manage_policies_navigation(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') @pytest.mark.polarion('10031') def test_check_compliance(random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ random_image_instance.assign_policy_profiles('OpenSCAP profile') random_image_instance.check_compliance() def get_table_attr(instance, table_name, attr): # Trying to read the table <table_name> attribute <attr> view = navigate_to(instance, 'Details', force=True) table = getattr(view.entities, table_name, None) if table: return table.read().get(attr) @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def test_containers_smartstate_analysis(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') random_image_instance.perform_smartstate_analysis(wait_for_finish=True) view = navigate_to(random_image_instance, 'Details') for tbl, attr, verifier in test_item.tested_attr: table = getattr(view.entities, tbl) table_data = {k.lower(): v for k, v in table.read().items()} if not soft_assert(attr.lower() in table_data, f'{tbl} table has missing attribute \'{attr}\''): continue provider.refresh_provider_relationships() wait_for_retval = wait_for(lambda: get_table_attr(random_image_instance, tbl, attr), message='Trying to get attribute "{}" of table "{}"'.format( attr, tbl), delay=5, num_sec=120, silent_failure=True) if not wait_for_retval: soft_assert(False, 'Could not get attribute "{}" for "{}" table.' .format(attr, tbl)) continue value = wait_for_retval.out soft_assert(verifier(value), f'{tbl}.{attr} attribute has unexpected value ({value})') @pytest.mark.parametrize(('test_item'), TEST_ITEMS) def <|fim_middle|>(provider, test_item, soft_assert, delete_all_container_tasks, random_image_instance): """ Test initiating a SmartState Analysis scan via the CFME API through the ManageIQ API Client entity class. RFE: BZ 1486362 Polarion: assignee: juwatts caseimportance: high casecomponent: Containers initialEstimate: 1/6h """ if test_item.is_openscap: random_image_instance.assign_policy_profiles('OpenSCAP profile') else: random_image_instance.unassign_policy_profiles('OpenSCAP profile') original_scan = random_image_instance.last_scan_attempt_on random_image_instance.scan() task = provider.appliance.collections.tasks.instantiate( name=f"Container Image Analysis: '{random_image_instance.name}'", tab='AllTasks') task.wait_for_finished() soft_assert(original_scan != random_image_instance.last_scan_attempt_on, 'SmartState Anaysis scan has failed') <|fim▁end|>
test_containers_smartstate_analysis_api
<|file_name|>urls.py<|end_file_name|><|fim▁begin|>from django.conf.urls.defaults import * """ Also used in cms.tests.ApphooksTestCase """ urlpatterns = patterns('cms.test_utils.project.sampleapp.views', url(r'^$', 'sample_view', {'message': 'sample root page',}, name='sample-root'), url(r'^settings/$', 'sample_view', kwargs={'message': 'sample settings page'}, name='sample-settings'), url(r'^account/$', 'sample_view', {'message': 'sample account page'}, name='sample-account'), url(r'^account/my_profile/$', 'sample_view', {'message': 'sample my profile page'}, name='sample-profile'), url(r'^(?P<id>[0-9]+)/$', 'category_view', name='category_view'), url(r'^notfound/$', 'notfound', name='notfound'),<|fim▁hole|><|fim▁end|>
url(r'^extra_1/$', 'extra_view', {'message': 'test urlconf'}, name='extra_first'), url(r'^', include('cms.test_utils.project.sampleapp.urls_extra')), )
<|file_name|>setup.py<|end_file_name|><|fim▁begin|>import os from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(here, 'README.md')) as f: README = f.read() with open(os.path.join(here, 'CHANGES.md')) as f: CHANGES = f.read() requires = [ 'pyramid', 'pyramid_jinja2', 'pyramid_debugtoolbar', 'pyramid_tm', 'SQLAlchemy', 'transaction', 'zope.sqlalchemy', 'waitress', ] setup(name='guestbook', version='0.1',<|fim▁hole|> "Programming Language :: Python :: 3", "Framework :: Pyramid", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", ], author='', author_email='', url='', keywords='web wsgi bfg pylons pyramid', packages=find_packages(), include_package_data=True, zip_safe=False, test_suite='guestbook', install_requires=requires, entry_points="""\ [paste.app_factory] main = guestbook:main [console_scripts] initialize_guestbook_db = guestbook.scripts.initializedb:main """, )<|fim▁end|>
description='guestbook', long_description=README + '\n\n' + CHANGES, classifiers=[
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app<|fim▁hole|>class DestinationFactoryError(AutocertError): def __init__(self, destination): msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg) def create_destination(destination, ar, cfg, timeout, verbosity): d = None if destination == 'aws': d = AwsDestination(ar, cfg, verbosity) elif destination == 'zeus': d = ZeusDestination(ar, cfg, verbosity) else: raise DestinationFactoryError(destination) dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): return d<|fim▁end|>
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app class DestinationFactoryError(AutocertError): <|fim_middle|> def create_destination(destination, ar, cfg, timeout, verbosity): d = None if destination == 'aws': d = AwsDestination(ar, cfg, verbosity) elif destination == 'zeus': d = ZeusDestination(ar, cfg, verbosity) else: raise DestinationFactoryError(destination) dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): return d <|fim▁end|>
def __init__(self, destination): msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg)
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app class DestinationFactoryError(AutocertError): def __init__(self, destination): <|fim_middle|> def create_destination(destination, ar, cfg, timeout, verbosity): d = None if destination == 'aws': d = AwsDestination(ar, cfg, verbosity) elif destination == 'zeus': d = ZeusDestination(ar, cfg, verbosity) else: raise DestinationFactoryError(destination) dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): return d <|fim▁end|>
msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg)
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app class DestinationFactoryError(AutocertError): def __init__(self, destination): msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg) def create_destination(destination, ar, cfg, timeout, verbosity): <|fim_middle|> <|fim▁end|>
d = None if destination == 'aws': d = AwsDestination(ar, cfg, verbosity) elif destination == 'zeus': d = ZeusDestination(ar, cfg, verbosity) else: raise DestinationFactoryError(destination) dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): return d
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app class DestinationFactoryError(AutocertError): def __init__(self, destination): msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg) def create_destination(destination, ar, cfg, timeout, verbosity): d = None if destination == 'aws': <|fim_middle|> elif destination == 'zeus': d = ZeusDestination(ar, cfg, verbosity) else: raise DestinationFactoryError(destination) dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): return d <|fim▁end|>
d = AwsDestination(ar, cfg, verbosity)
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app class DestinationFactoryError(AutocertError): def __init__(self, destination): msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg) def create_destination(destination, ar, cfg, timeout, verbosity): d = None if destination == 'aws': d = AwsDestination(ar, cfg, verbosity) elif destination == 'zeus': <|fim_middle|> else: raise DestinationFactoryError(destination) dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): return d <|fim▁end|>
d = ZeusDestination(ar, cfg, verbosity)
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app class DestinationFactoryError(AutocertError): def __init__(self, destination): msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg) def create_destination(destination, ar, cfg, timeout, verbosity): d = None if destination == 'aws': d = AwsDestination(ar, cfg, verbosity) elif destination == 'zeus': d = ZeusDestination(ar, cfg, verbosity) else: <|fim_middle|> dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): return d <|fim▁end|>
raise DestinationFactoryError(destination)
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app class DestinationFactoryError(AutocertError): def __init__(self, destination): msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg) def create_destination(destination, ar, cfg, timeout, verbosity): d = None if destination == 'aws': d = AwsDestination(ar, cfg, verbosity) elif destination == 'zeus': d = ZeusDestination(ar, cfg, verbosity) else: raise DestinationFactoryError(destination) dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): <|fim_middle|> <|fim▁end|>
return d
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app class DestinationFactoryError(AutocertError): def <|fim_middle|>(self, destination): msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg) def create_destination(destination, ar, cfg, timeout, verbosity): d = None if destination == 'aws': d = AwsDestination(ar, cfg, verbosity) elif destination == 'zeus': d = ZeusDestination(ar, cfg, verbosity) else: raise DestinationFactoryError(destination) dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): return d <|fim▁end|>
__init__
<|file_name|>factory.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' destination.factory ''' from destination.zeus import ZeusDestination from destination.aws import AwsDestination from exceptions import AutocertError from config import CFG from app import app class DestinationFactoryError(AutocertError): def __init__(self, destination): msg = f'destination factory error with {destination}' super(DestinationFactoryError, self).__init__(msg) def <|fim_middle|>(destination, ar, cfg, timeout, verbosity): d = None if destination == 'aws': d = AwsDestination(ar, cfg, verbosity) elif destination == 'zeus': d = ZeusDestination(ar, cfg, verbosity) else: raise DestinationFactoryError(destination) dests = list(CFG.destinations.zeus.keys()) if d.has_connectivity(timeout, dests): return d <|fim▁end|>
create_destination
<|file_name|>views.py<|end_file_name|><|fim▁begin|>from django.shortcuts import render def about(request):<|fim▁hole|> return render(request, "about.html", {}) def location(request): return render(request, "location.html", {}) def failure(request): return render(request, "failure.html", {})<|fim▁end|>
<|file_name|>views.py<|end_file_name|><|fim▁begin|>from django.shortcuts import render def about(request): <|fim_middle|> def location(request): return render(request, "location.html", {}) def failure(request): return render(request, "failure.html", {}) <|fim▁end|>
return render(request, "about.html", {})
<|file_name|>views.py<|end_file_name|><|fim▁begin|>from django.shortcuts import render def about(request): return render(request, "about.html", {}) def location(request): <|fim_middle|> def failure(request): return render(request, "failure.html", {}) <|fim▁end|>
return render(request, "location.html", {})
<|file_name|>views.py<|end_file_name|><|fim▁begin|>from django.shortcuts import render def about(request): return render(request, "about.html", {}) def location(request): return render(request, "location.html", {}) def failure(request): <|fim_middle|> <|fim▁end|>
return render(request, "failure.html", {})
<|file_name|>views.py<|end_file_name|><|fim▁begin|>from django.shortcuts import render def <|fim_middle|>(request): return render(request, "about.html", {}) def location(request): return render(request, "location.html", {}) def failure(request): return render(request, "failure.html", {}) <|fim▁end|>
about
<|file_name|>views.py<|end_file_name|><|fim▁begin|>from django.shortcuts import render def about(request): return render(request, "about.html", {}) def <|fim_middle|>(request): return render(request, "location.html", {}) def failure(request): return render(request, "failure.html", {}) <|fim▁end|>
location
<|file_name|>views.py<|end_file_name|><|fim▁begin|>from django.shortcuts import render def about(request): return render(request, "about.html", {}) def location(request): return render(request, "location.html", {}) def <|fim_middle|>(request): return render(request, "failure.html", {}) <|fim▁end|>
failure
<|file_name|>download.py<|end_file_name|><|fim▁begin|>""" Downloads the following: - Korean Wikipedia texts - Korean """ from sqlparse import parsestream from sqlparse.sql import Parenthesis for statement in parsestream(open('data/test.sql')): texts = [str(token.tokens[1].tokens[-1]).decode('string_escape') for token in statement.tokens if isinstance(token, Parenthesis)]<|fim▁hole|><|fim▁end|>
print texts texts = [text for text in texts if text[0] != '#'] if texts: print "\n===\n".join(texts)
<|file_name|>download.py<|end_file_name|><|fim▁begin|>""" Downloads the following: - Korean Wikipedia texts - Korean """ from sqlparse import parsestream from sqlparse.sql import Parenthesis for statement in parsestream(open('data/test.sql')): texts = [str(token.tokens[1].tokens[-1]).decode('string_escape') for token in statement.tokens if isinstance(token, Parenthesis)] print texts texts = [text for text in texts if text[0] != '#'] if texts: <|fim_middle|> <|fim▁end|>
print "\n===\n".join(texts)
<|file_name|>static_images.py<|end_file_name|><|fim▁begin|>import json import requests import key API_key = key.getAPIkey() #load all champion pictures def load_champion_pictures(champion_json): print len(champion_json['data']) version = champion_json['version'] print "version: " + version for champion in champion_json['data']: print champion<|fim▁hole|> if r.status_code == 200: img = r.content with open('static/images/champions/' + champion_json['data'][champion]['name'] + '.png', 'w') as f: f.write(img) print "img created" else: print "pictures: something went wrong" #load champion json #converts to python dict using json() and json.dump() for error checking def load_champion_json(): try: r = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?&api_key=' + API_key) champion_json = r.json() if 'status' in champion_json: print champion_json['status']['message'] return load_champion_pictures(champion_json) # quick fix to change MonkeyKing to Wukong so that sort_keys sorts it properly champion_json['data']['Wukong'] = champion_json['data']['MonkeyKing'] del champion_json['data']['MonkeyKing'] except ValueError as e: print e.message return with open('static/json/champion.json', 'w') as f: json.dump(champion_json, f, sort_keys=True) load_champion_json()<|fim▁end|>
r = requests.get('http://ddragon.leagueoflegends.com/cdn/' + version + '/img/champion/' + champion + '.png')
<|file_name|>static_images.py<|end_file_name|><|fim▁begin|>import json import requests import key API_key = key.getAPIkey() #load all champion pictures def load_champion_pictures(champion_json): <|fim_middle|> #load champion json #converts to python dict using json() and json.dump() for error checking def load_champion_json(): try: r = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?&api_key=' + API_key) champion_json = r.json() if 'status' in champion_json: print champion_json['status']['message'] return load_champion_pictures(champion_json) # quick fix to change MonkeyKing to Wukong so that sort_keys sorts it properly champion_json['data']['Wukong'] = champion_json['data']['MonkeyKing'] del champion_json['data']['MonkeyKing'] except ValueError as e: print e.message return with open('static/json/champion.json', 'w') as f: json.dump(champion_json, f, sort_keys=True) load_champion_json() <|fim▁end|>
print len(champion_json['data']) version = champion_json['version'] print "version: " + version for champion in champion_json['data']: print champion r = requests.get('http://ddragon.leagueoflegends.com/cdn/' + version + '/img/champion/' + champion + '.png') if r.status_code == 200: img = r.content with open('static/images/champions/' + champion_json['data'][champion]['name'] + '.png', 'w') as f: f.write(img) print "img created" else: print "pictures: something went wrong"
<|file_name|>static_images.py<|end_file_name|><|fim▁begin|>import json import requests import key API_key = key.getAPIkey() #load all champion pictures def load_champion_pictures(champion_json): print len(champion_json['data']) version = champion_json['version'] print "version: " + version for champion in champion_json['data']: print champion r = requests.get('http://ddragon.leagueoflegends.com/cdn/' + version + '/img/champion/' + champion + '.png') if r.status_code == 200: img = r.content with open('static/images/champions/' + champion_json['data'][champion]['name'] + '.png', 'w') as f: f.write(img) print "img created" else: print "pictures: something went wrong" #load champion json #converts to python dict using json() and json.dump() for error checking def load_champion_json(): <|fim_middle|> load_champion_json() <|fim▁end|>
try: r = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?&api_key=' + API_key) champion_json = r.json() if 'status' in champion_json: print champion_json['status']['message'] return load_champion_pictures(champion_json) # quick fix to change MonkeyKing to Wukong so that sort_keys sorts it properly champion_json['data']['Wukong'] = champion_json['data']['MonkeyKing'] del champion_json['data']['MonkeyKing'] except ValueError as e: print e.message return with open('static/json/champion.json', 'w') as f: json.dump(champion_json, f, sort_keys=True)
<|file_name|>static_images.py<|end_file_name|><|fim▁begin|>import json import requests import key API_key = key.getAPIkey() #load all champion pictures def load_champion_pictures(champion_json): print len(champion_json['data']) version = champion_json['version'] print "version: " + version for champion in champion_json['data']: print champion r = requests.get('http://ddragon.leagueoflegends.com/cdn/' + version + '/img/champion/' + champion + '.png') if r.status_code == 200: <|fim_middle|> else: print "pictures: something went wrong" #load champion json #converts to python dict using json() and json.dump() for error checking def load_champion_json(): try: r = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?&api_key=' + API_key) champion_json = r.json() if 'status' in champion_json: print champion_json['status']['message'] return load_champion_pictures(champion_json) # quick fix to change MonkeyKing to Wukong so that sort_keys sorts it properly champion_json['data']['Wukong'] = champion_json['data']['MonkeyKing'] del champion_json['data']['MonkeyKing'] except ValueError as e: print e.message return with open('static/json/champion.json', 'w') as f: json.dump(champion_json, f, sort_keys=True) load_champion_json() <|fim▁end|>
img = r.content with open('static/images/champions/' + champion_json['data'][champion]['name'] + '.png', 'w') as f: f.write(img) print "img created"
<|file_name|>static_images.py<|end_file_name|><|fim▁begin|>import json import requests import key API_key = key.getAPIkey() #load all champion pictures def load_champion_pictures(champion_json): print len(champion_json['data']) version = champion_json['version'] print "version: " + version for champion in champion_json['data']: print champion r = requests.get('http://ddragon.leagueoflegends.com/cdn/' + version + '/img/champion/' + champion + '.png') if r.status_code == 200: img = r.content with open('static/images/champions/' + champion_json['data'][champion]['name'] + '.png', 'w') as f: f.write(img) print "img created" else: <|fim_middle|> #load champion json #converts to python dict using json() and json.dump() for error checking def load_champion_json(): try: r = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?&api_key=' + API_key) champion_json = r.json() if 'status' in champion_json: print champion_json['status']['message'] return load_champion_pictures(champion_json) # quick fix to change MonkeyKing to Wukong so that sort_keys sorts it properly champion_json['data']['Wukong'] = champion_json['data']['MonkeyKing'] del champion_json['data']['MonkeyKing'] except ValueError as e: print e.message return with open('static/json/champion.json', 'w') as f: json.dump(champion_json, f, sort_keys=True) load_champion_json() <|fim▁end|>
print "pictures: something went wrong"
<|file_name|>static_images.py<|end_file_name|><|fim▁begin|>import json import requests import key API_key = key.getAPIkey() #load all champion pictures def load_champion_pictures(champion_json): print len(champion_json['data']) version = champion_json['version'] print "version: " + version for champion in champion_json['data']: print champion r = requests.get('http://ddragon.leagueoflegends.com/cdn/' + version + '/img/champion/' + champion + '.png') if r.status_code == 200: img = r.content with open('static/images/champions/' + champion_json['data'][champion]['name'] + '.png', 'w') as f: f.write(img) print "img created" else: print "pictures: something went wrong" #load champion json #converts to python dict using json() and json.dump() for error checking def load_champion_json(): try: r = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?&api_key=' + API_key) champion_json = r.json() if 'status' in champion_json: <|fim_middle|> load_champion_pictures(champion_json) # quick fix to change MonkeyKing to Wukong so that sort_keys sorts it properly champion_json['data']['Wukong'] = champion_json['data']['MonkeyKing'] del champion_json['data']['MonkeyKing'] except ValueError as e: print e.message return with open('static/json/champion.json', 'w') as f: json.dump(champion_json, f, sort_keys=True) load_champion_json() <|fim▁end|>
print champion_json['status']['message'] return
<|file_name|>static_images.py<|end_file_name|><|fim▁begin|>import json import requests import key API_key = key.getAPIkey() #load all champion pictures def <|fim_middle|>(champion_json): print len(champion_json['data']) version = champion_json['version'] print "version: " + version for champion in champion_json['data']: print champion r = requests.get('http://ddragon.leagueoflegends.com/cdn/' + version + '/img/champion/' + champion + '.png') if r.status_code == 200: img = r.content with open('static/images/champions/' + champion_json['data'][champion]['name'] + '.png', 'w') as f: f.write(img) print "img created" else: print "pictures: something went wrong" #load champion json #converts to python dict using json() and json.dump() for error checking def load_champion_json(): try: r = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?&api_key=' + API_key) champion_json = r.json() if 'status' in champion_json: print champion_json['status']['message'] return load_champion_pictures(champion_json) # quick fix to change MonkeyKing to Wukong so that sort_keys sorts it properly champion_json['data']['Wukong'] = champion_json['data']['MonkeyKing'] del champion_json['data']['MonkeyKing'] except ValueError as e: print e.message return with open('static/json/champion.json', 'w') as f: json.dump(champion_json, f, sort_keys=True) load_champion_json() <|fim▁end|>
load_champion_pictures
<|file_name|>static_images.py<|end_file_name|><|fim▁begin|>import json import requests import key API_key = key.getAPIkey() #load all champion pictures def load_champion_pictures(champion_json): print len(champion_json['data']) version = champion_json['version'] print "version: " + version for champion in champion_json['data']: print champion r = requests.get('http://ddragon.leagueoflegends.com/cdn/' + version + '/img/champion/' + champion + '.png') if r.status_code == 200: img = r.content with open('static/images/champions/' + champion_json['data'][champion]['name'] + '.png', 'w') as f: f.write(img) print "img created" else: print "pictures: something went wrong" #load champion json #converts to python dict using json() and json.dump() for error checking def <|fim_middle|>(): try: r = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?&api_key=' + API_key) champion_json = r.json() if 'status' in champion_json: print champion_json['status']['message'] return load_champion_pictures(champion_json) # quick fix to change MonkeyKing to Wukong so that sort_keys sorts it properly champion_json['data']['Wukong'] = champion_json['data']['MonkeyKing'] del champion_json['data']['MonkeyKing'] except ValueError as e: print e.message return with open('static/json/champion.json', 'w') as f: json.dump(champion_json, f, sort_keys=True) load_champion_json() <|fim▁end|>
load_champion_json
<|file_name|>v_univar.py<|end_file_name|><|fim▁begin|><|fim▁hole|>*************************************************************************** v_univar.py --------------------- Date : December 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'Victor Olaya' __date__ = 'December 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' def postProcessResults(alg): htmlFile = alg.getOutputFromName('html').value found = False f = open(htmlFile, "w") f.write("<h2>v.univar</h2>\n") for line in alg.consoleOutput: if found and not line.strip().endswith('exit'): f.write(line + "<br>\n") if 'v.univar' in line: found = True f.close()<|fim▁end|>
# -*- coding: utf-8 -*- """
<|file_name|>v_univar.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ *************************************************************************** v_univar.py --------------------- Date : December 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'Victor Olaya' __date__ = 'December 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' def postProcessResults(alg): <|fim_middle|> <|fim▁end|>
htmlFile = alg.getOutputFromName('html').value found = False f = open(htmlFile, "w") f.write("<h2>v.univar</h2>\n") for line in alg.consoleOutput: if found and not line.strip().endswith('exit'): f.write(line + "<br>\n") if 'v.univar' in line: found = True f.close()
<|file_name|>v_univar.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ *************************************************************************** v_univar.py --------------------- Date : December 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'Victor Olaya' __date__ = 'December 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' def postProcessResults(alg): htmlFile = alg.getOutputFromName('html').value found = False f = open(htmlFile, "w") f.write("<h2>v.univar</h2>\n") for line in alg.consoleOutput: if found and not line.strip().endswith('exit'): <|fim_middle|> if 'v.univar' in line: found = True f.close() <|fim▁end|>
f.write(line + "<br>\n")
<|file_name|>v_univar.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ *************************************************************************** v_univar.py --------------------- Date : December 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'Victor Olaya' __date__ = 'December 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' def postProcessResults(alg): htmlFile = alg.getOutputFromName('html').value found = False f = open(htmlFile, "w") f.write("<h2>v.univar</h2>\n") for line in alg.consoleOutput: if found and not line.strip().endswith('exit'): f.write(line + "<br>\n") if 'v.univar' in line: <|fim_middle|> f.close() <|fim▁end|>
found = True
<|file_name|>v_univar.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ *************************************************************************** v_univar.py --------------------- Date : December 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'Victor Olaya' __date__ = 'December 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' def <|fim_middle|>(alg): htmlFile = alg.getOutputFromName('html').value found = False f = open(htmlFile, "w") f.write("<h2>v.univar</h2>\n") for line in alg.consoleOutput: if found and not line.strip().endswith('exit'): f.write(line + "<br>\n") if 'v.univar' in line: found = True f.close() <|fim▁end|>
postProcessResults
<|file_name|>ipc_perftest.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python3 # @begin:license # # Copyright (c) 2015-2019, Benjamin Niemann <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # @end:license<|fim▁hole|>import logging import random from . import ipc_test_pb2 from . import ipc_test logger = logging.getLogger(__name__) class IPCPerfTest(ipc_test.IPCPerfTestBase): async def test_small_messages(self): request = ipc_test_pb2.TestRequest() request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 5000) async def test_large_messages(self): request = ipc_test_pb2.TestRequest() for _ in range(10000): request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 100)<|fim▁end|>
<|file_name|>ipc_perftest.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python3 # @begin:license # # Copyright (c) 2015-2019, Benjamin Niemann <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # @end:license import logging import random from . import ipc_test_pb2 from . import ipc_test logger = logging.getLogger(__name__) class IPCPerfTest(ipc_test.IPCPerfTestBase): <|fim_middle|> <|fim▁end|>
async def test_small_messages(self): request = ipc_test_pb2.TestRequest() request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 5000) async def test_large_messages(self): request = ipc_test_pb2.TestRequest() for _ in range(10000): request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 100)
<|file_name|>ipc_perftest.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python3 # @begin:license # # Copyright (c) 2015-2019, Benjamin Niemann <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # @end:license import logging import random from . import ipc_test_pb2 from . import ipc_test logger = logging.getLogger(__name__) class IPCPerfTest(ipc_test.IPCPerfTestBase): async def test_small_messages(self): <|fim_middle|> async def test_large_messages(self): request = ipc_test_pb2.TestRequest() for _ in range(10000): request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 100) <|fim▁end|>
request = ipc_test_pb2.TestRequest() request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 5000)
<|file_name|>ipc_perftest.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python3 # @begin:license # # Copyright (c) 2015-2019, Benjamin Niemann <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # @end:license import logging import random from . import ipc_test_pb2 from . import ipc_test logger = logging.getLogger(__name__) class IPCPerfTest(ipc_test.IPCPerfTestBase): async def test_small_messages(self): request = ipc_test_pb2.TestRequest() request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 5000) async def test_large_messages(self): <|fim_middle|> <|fim▁end|>
request = ipc_test_pb2.TestRequest() for _ in range(10000): request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 100)
<|file_name|>ipc_perftest.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python3 # @begin:license # # Copyright (c) 2015-2019, Benjamin Niemann <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # @end:license import logging import random from . import ipc_test_pb2 from . import ipc_test logger = logging.getLogger(__name__) class IPCPerfTest(ipc_test.IPCPerfTestBase): async def <|fim_middle|>(self): request = ipc_test_pb2.TestRequest() request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 5000) async def test_large_messages(self): request = ipc_test_pb2.TestRequest() for _ in range(10000): request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 100) <|fim▁end|>
test_small_messages
<|file_name|>ipc_perftest.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python3 # @begin:license # # Copyright (c) 2015-2019, Benjamin Niemann <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # @end:license import logging import random from . import ipc_test_pb2 from . import ipc_test logger = logging.getLogger(__name__) class IPCPerfTest(ipc_test.IPCPerfTestBase): async def test_small_messages(self): request = ipc_test_pb2.TestRequest() request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 5000) async def <|fim_middle|>(self): request = ipc_test_pb2.TestRequest() for _ in range(10000): request.t.add(numerator=random.randint(0, 4), denominator=random.randint(1, 2)) await self.run_test(request, 100) <|fim▁end|>
test_large_messages
<|file_name|>addons.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, print_function, division from mitmproxy import exceptions import pprint def _get_name(itm): return getattr(itm, "name", itm.__class__.__name__) class Addons(object): def __init__(self, master): self.chain = [] self.master = master master.options.changed.connect(self.options_update) def options_update(self, options, updated): for i in self.chain: with self.master.handlecontext(): i.configure(options, updated) def add(self, options, *addons): if not addons: raise ValueError("No addons specified.") self.chain.extend(addons) for i in addons: self.invoke_with_context(i, "start") self.invoke_with_context( i, "configure", self.master.options, self.master.options.keys() ) def remove(self, addon): self.chain = [i for i in self.chain if i is not addon] self.invoke_with_context(addon, "done") def done(self): for i in self.chain: self.invoke_with_context(i, "done") def has_addon(self, name): """ Is an addon with this name registered? """ for i in self.chain: if _get_name(i) == name: return True def __len__(self): return len(self.chain) def __str__(self): return pprint.pformat([str(i) for i in self.chain]) def invoke_with_context(self, addon, name, *args, **kwargs): with self.master.handlecontext(): self.invoke(addon, name, *args, **kwargs) def invoke(self, addon, name, *args, **kwargs): func = getattr(addon, name, None) if func: if not callable(func): raise exceptions.AddonError( "Addon handler %s not callable" % name ) <|fim▁hole|> def __call__(self, name, *args, **kwargs): for i in self.chain: self.invoke(i, name, *args, **kwargs)<|fim▁end|>
func(*args, **kwargs)
<|file_name|>addons.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, print_function, division from mitmproxy import exceptions import pprint def _get_name(itm): <|fim_middle|> class Addons(object): def __init__(self, master): self.chain = [] self.master = master master.options.changed.connect(self.options_update) def options_update(self, options, updated): for i in self.chain: with self.master.handlecontext(): i.configure(options, updated) def add(self, options, *addons): if not addons: raise ValueError("No addons specified.") self.chain.extend(addons) for i in addons: self.invoke_with_context(i, "start") self.invoke_with_context( i, "configure", self.master.options, self.master.options.keys() ) def remove(self, addon): self.chain = [i for i in self.chain if i is not addon] self.invoke_with_context(addon, "done") def done(self): for i in self.chain: self.invoke_with_context(i, "done") def has_addon(self, name): """ Is an addon with this name registered? """ for i in self.chain: if _get_name(i) == name: return True def __len__(self): return len(self.chain) def __str__(self): return pprint.pformat([str(i) for i in self.chain]) def invoke_with_context(self, addon, name, *args, **kwargs): with self.master.handlecontext(): self.invoke(addon, name, *args, **kwargs) def invoke(self, addon, name, *args, **kwargs): func = getattr(addon, name, None) if func: if not callable(func): raise exceptions.AddonError( "Addon handler %s not callable" % name ) func(*args, **kwargs) def __call__(self, name, *args, **kwargs): for i in self.chain: self.invoke(i, name, *args, **kwargs) <|fim▁end|>
return getattr(itm, "name", itm.__class__.__name__)
<|file_name|>addons.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, print_function, division from mitmproxy import exceptions import pprint def _get_name(itm): return getattr(itm, "name", itm.__class__.__name__) class Addons(object): <|fim_middle|> <|fim▁end|>
def __init__(self, master): self.chain = [] self.master = master master.options.changed.connect(self.options_update) def options_update(self, options, updated): for i in self.chain: with self.master.handlecontext(): i.configure(options, updated) def add(self, options, *addons): if not addons: raise ValueError("No addons specified.") self.chain.extend(addons) for i in addons: self.invoke_with_context(i, "start") self.invoke_with_context( i, "configure", self.master.options, self.master.options.keys() ) def remove(self, addon): self.chain = [i for i in self.chain if i is not addon] self.invoke_with_context(addon, "done") def done(self): for i in self.chain: self.invoke_with_context(i, "done") def has_addon(self, name): """ Is an addon with this name registered? """ for i in self.chain: if _get_name(i) == name: return True def __len__(self): return len(self.chain) def __str__(self): return pprint.pformat([str(i) for i in self.chain]) def invoke_with_context(self, addon, name, *args, **kwargs): with self.master.handlecontext(): self.invoke(addon, name, *args, **kwargs) def invoke(self, addon, name, *args, **kwargs): func = getattr(addon, name, None) if func: if not callable(func): raise exceptions.AddonError( "Addon handler %s not callable" % name ) func(*args, **kwargs) def __call__(self, name, *args, **kwargs): for i in self.chain: self.invoke(i, name, *args, **kwargs)