def only_show_issue_types(team_id=None, channel=None, params=None): (graph_name, graph, params) = Graph_Filters._get_graph_from_params( team_id, channel, params) if graph: Filters().setup(graph).only_show_issue_types(params) return Graph_Filters._save_graph_and_send_slack_message( team_id, channel, graph, graph_name)
def remove_link_types(team_id=None, channel=None, params=None): (graph_name, graph, params) = Graph_Filters._get_graph_from_params( team_id, channel, params) # get graph object if graph: Filters().setup(graph).remove_link_types(params) return Graph_Filters._save_graph_and_send_slack_message( team_id, channel, graph, graph_name) # save graph in ELK and send updates via Slack
def remove_issue_types(team_id=None, channel=None, params=None): (graph_name, graph, params) = Graph_Filters._get_graph_from_params( team_id, channel, params) if graph: Filters().setup(graph).remove_field_equal_to('Issue Type', params) return Graph_Filters._save_graph_and_send_slack_message( team_id, channel, graph, graph_name)
def only_links_between_nodes(team_id=None, channel=None, params=[]): (text, attachments) = Graph_Filters._check_params(params, ['Graph Name']) if text: return text, attachments graph_name = params[0] graph = Graph_Filters._get_graph(graph_name) if graph: Filters().setup(graph).only_links_between_nodes() return Graph_Filters._save_graph_and_send_slack_message( team_id, channel, graph, graph_name)
def only_with_field_equal_to(team_id=None, channel=None, params=None): (text, attachments) = Graph_Filters._check_params( params, ['Graph Name', 'Field Name', 'Field Value']) if text: return text, attachments graph_name = params.pop(0) field_name = params.pop(0) values = " ".join(params).split(',') graph = Graph_Filters._get_graph(graph_name) if graph: Filters().setup(graph).only_with_field_equal_to(field_name, values) return Graph_Filters._save_graph_and_send_slack_message( team_id, channel, graph, graph_name)
def group_by_field(team_id=None, channel=None, params=None): if len(params) < 2: return slack_message( ':red_circle: For this filter, you need to provide a `graph_name` and a `field` name: ', [], channel, team_id) graph_name = params.pop(0) field_name = ' '.join(params) slack_message( ":point_right: Creating new graph using the `group_by_field` filter on the `{0}` field of the `{1}` graph" .format(field_name, graph_name), [], channel, team_id) graph = Graph_Filters._get_graph(graph_name) if graph: Filters().setup(graph).group_by_field(graph_name, field_name) return Graph_Filters._save_graph_and_send_slack_message( team_id, channel, graph, graph_name) else: slack_message(f':red_circle: graph *{graph_name}* not found', [], channel)
def filter(self): from osbot_jira.api.graph.Filters import Filters return Filters().setup(graph=self)
def setUp(self): super().setUp() self.graph: GS_Graph = None self.filters = Filters() self.result = None
class test_Filters(Test_Helper): def setUp(self): super().setUp() self.graph: GS_Graph = None self.filters = Filters() self.result = None def tearDown(self): if self.result is not None: Dev.pprint(self.result) # helper methods def get_graph_json(self, graph_name): return self.filters.lambda_graph().load_gs_graph(graph_name).to_json( store_issues=True) def get_graph(self, graph_name): graph_json: str = self.get_graph_json(graph_name) graph: GS_Graph = GS_Graph().from_json(graph_json) return graph def use_graph(self, graph_name): self.graph = self.get_graph(graph_name) return self.filters.setup(graph=self.graph) def show_graph(self): self.filters.graph.render_puml_and_save_tmp() # class methods def test__init__(self): assert self.filters.graph is None def test_group_by_field(self): root_node = 'Group by field' self.use_graph('graph_8SX').group_by_field(root_node, 'Project') assert root_node in self.graph.nodes assert 'IT Assets' in self.graph.nodes def test_group_by_field__Issue_Links( self): # Issue_Links are handled differently root_node = 'Group by field' self.use_graph('graph_9G8').group_by_field(root_node, 'Issue Links') assert root_node in self.graph.nodes assert 'has RISK' in self.graph.nodes def test_only_with_issue_types(self): graph_name = 'graph_9G8' issue_types = ['Risk'] graph = self.get_graph(graph_name) assert sorted(graph.issues__issue_types()) == [ 'Business entity', 'IT Asset', 'People', 'Risk' ] self.filters.setup(graph=graph).only_with_issue_types(issue_types) assert graph.issues__issue_types() == ['Risk'] #self.result = graph.render_puml_and_save_tmp() def test_only_show_issue_types(self): graph_name = 'graph_9G8' issue_types = ['People'] graph = self.get_graph(graph_name) self.filters.setup(graph=graph).only_show_issue_types(issue_types) def test_only_link_types(self): graph_name = 'graph_XTK' link_types = ['has RISK'] graph = self.get_graph(graph_name) assert graph.edges__link_types() == [ 'has Business Owner', 'has RISK', 'has Technical Owner', 'is child of', 'is managed by' ] self.filters.setup(graph=graph).only_with_link_types(link_types) assert graph.edges__link_types() == link_types def test_only_with_field_equal_to(self): graph_name = 'graph_9G8' field = 'Issue Type' values = ['People'] graph = self.get_graph(graph_name) self.result = graph.nodes__field_values('Issue Type') assert graph.nodes__field_values('Issue Type') == [ 'Business entity', 'IT Asset', 'People', 'Risk' ] self.filters.setup(graph=graph).only_with_field_equal_to(field, values) assert graph.nodes__field_values('Issue Type') == values def test_only_links_between_nodes(self): self.use_graph('graph_I6I').only_links_between_nodes() #assert self.filters.graph.edges__link_types() == [ 'RISK affects', 'has Business Owner', 'has RISK', 'has Technical Owner', 'is Business Owner', 'is Technical Owner', 'is child of', 'is managed by', 'is manager of', 'is parent of'] #self.show_graph() def test_remove_field_equal_to(self): self.use_graph('graph_9G8').remove_field_equal_to( 'Issue Type', ['Risk', 'People']) assert self.graph.nodes__field_values('Issue Type') == [ 'Business entity', 'IT Asset' ] def test_remove_nodes_with_issue_types(self): self.use_graph('graph_9G8').remove_nodes_with_issue_types( ['Risk', 'People']) assert self.graph.nodes__field_values('Issue Type') == [ 'Business entity', 'IT Asset' ] def test_remove_nodes_from_projects(self): self.use_graph('graph_9G8').remove_nodes_from_projects(['GS People']) assert self.graph.nodes__field_values('Project') == [ 'IT Assets', 'RISK' ] def test_remove_link_types(self): self.use_graph('graph_9G8').remove_link_types( ['has RISK', 'is child of']) assert self.graph.edges__link_types() == [ 'has Business Owner', 'has Technical Owner', 'is managed by' ] self.show_graph() def test_search_by_field(self): self.use_graph('graph_NO9').search_by_field('Status', 'equals', 'Active') self.result = self.graph.nodes # self.use_graph('graph_9G8').search_by_field('Project','equals', 'gs people') # assert self.graph.edges__link_types() == ['is managed by'] # # self.use_graph('graph_9G8').search_by_field__equals('Project', 'Risk') # assert self.graph.edges__link_types() == ['has RISK'] # # self.use_graph('graph_9G8').search_by_field('Project', 'not equals', 'gs people') # assert self.graph.edges__link_types() == ['has RISK', 'is child of'] # # self.use_graph('graph_9G8').search_by_field__not_equals('Project', 'IT Assets') # assert self.graph.edges__link_types() == ['has RISK', 'is managed by'] # # self.use_graph('graph_9G8').search_by_field('Summary', 'contains', 'jira') # assert self.graph.edges__link_types() == ['has RISK'] # # self.use_graph('graph_9G8').search_by_field__contains('Summary', 'Group') # assert self.graph.edges__link_types() == ['has Business Owner', 'is child of'] # # self.use_graph('graph_9G8').search_by_field('Summary', 'not contains', 'jira') # assert self.graph.edges__link_types() == ['has Business Owner', 'has Technical Owner', 'is child of', 'is managed by'] # # self.use_graph('graph_9G8').search_by_field__not_contains('Summary', 'Group') # assert self.graph.edges__link_types() == ['has RISK', 'has Technical Owner', 'is child of', 'is managed by'] # #self.result = self.graph.edges__link_types() #self.show_graph() def test__graph_filter(self): graph: GS_Graph = self.use_graph('graph_9G8').graph graph.filter().remove_field_equal_to('Project', 'GS People') assert graph.edges__link_types() == ['has RISK', 'is child of']