Coverage for laskea/embed.py: 53.66%

89 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-10 22:19:18 +00:00

1"""Calculate (Finnish: laskea) some parts - embeddings.""" 

2from typing import Union, no_type_check 

3 

4from atlassian import Jira # type: ignore # noqa 

5 

6import laskea 

7import laskea.api.excel as exc 

8import laskea.api.jira as api 

9import laskea.api.tabulator as tab 

10 

11DB: dict[str, Union[None, Jira]] = {'handle': None} 

12 

13 

14@no_type_check 

15def mbom_table(configuration=None) -> None: 

16 """Public document interface.""" 

17 if configuration is None: 17 ↛ 18line 17 didn't jump to line 18, because the condition on line 17 was never true

18 configuration = laskea.EXCEL['mbom'] 

19 

20 print(exc.mbom_table(configuration)) 

21 

22 

23@no_type_check 

24def metrics_table(configuration=None) -> None: 

25 """Public document interface.""" 

26 if configuration is None: 

27 configuration = laskea.TABULATOR['overview'] 

28 

29 print(tab.tabulator_overview_table(configuration)) 

30 

31 

32@no_type_check 

33def kpi_table(selected, configuration=None) -> None: 

34 """Public document interface.""" 

35 if configuration is None: 

36 configuration = laskea.TABULATOR['metrics'] 

37 

38 print(tab.tabulator_kpi_table(configuration, selected)) 

39 

40 

41@no_type_check 

42def test_plans( 

43 parent_jql: str = '', 

44 children_jql: str = '', 

45 parent_type: str = 'Test Plan', 

46 children_type: str = 'Test Case', 

47 data=None, 

48) -> None: 

49 """Public document interface for the sub(sub)section document part generation from JIRA parents with children.""" 

50 if data is None: 

51 if not DB.get('handle', None): 

52 DB['handle'] = api.login() 

53 

54 print(api.parent_children_sections(DB['handle'], parent_jql, children_jql, parent_type, children_type)) 

55 else: 

56 print(api.parent_children_sections(DB['handle'], parent_jql, children_jql, parent_type, children_type, data)) 

57 

58 

59@no_type_check 

60def svl( 

61 query_text: str = '', 

62 key_magic: bool = False, 

63 field_sep: str = laskea.PIPE, 

64 replacement: str = laskea.FS_SLUG, 

65 data=None, 

66) -> None: 

67 """Public separated values list interface.""" 

68 if data is None: 68 ↛ 69line 68 didn't jump to line 69, because the condition on line 68 was never true

69 if not DB.get('handle', None): 

70 DB['handle'] = api.login() 

71 

72 print( 

73 api.separated_values_list( 

74 DB['handle'], query_text, key_magic=key_magic, field_sep=field_sep, replacement=replacement 

75 ) 

76 ) 

77 else: 

78 print( 

79 api.separated_values_list( 

80 DB['handle'], query_text, key_magic=key_magic, field_sep=field_sep, replacement=replacement, data=data 

81 ) 

82 ) 

83 

84 

85@no_type_check 

86def table(query_text: str = '', caption: str = '', column_fields=None, data=None) -> None: 

87 """Public document interface.""" 

88 if data is None: 88 ↛ 89line 88 didn't jump to line 89, because the condition on line 88 was never true

89 if not DB.get('handle', None): 

90 DB['handle'] = api.login() 

91 

92 print(api.markdown_table(DB['handle'], query_text, caption=caption, column_fields=column_fields)) 

93 else: 

94 print(api.markdown_table(DB['handle'], query_text, caption=caption, column_fields=column_fields, data=data)) 

95 

96 

97@no_type_check 

98def dl(query_text: str = '', data=None) -> None: 

99 """Public document interface for definition list.""" 

100 if data is None: 100 ↛ 101line 100 didn't jump to line 101, because the condition on line 100 was never true

101 if not DB.get('handle', None): 

102 DB['handle'] = api.login() 

103 

104 print(api.markdown_list(DB['handle'], query_text, list_type='dl')) 

105 else: 

106 print(api.markdown_list(DB['handle'], query_text, list_type='dl', data=data)) 

107 

108 

109@no_type_check 

110def ol(query_text: str = '', data=None) -> None: 

111 """Public document interface for ordered list.""" 

112 if data is None: 112 ↛ 113line 112 didn't jump to line 113, because the condition on line 112 was never true

113 if not DB.get('handle', None): 

114 DB['handle'] = api.login() 

115 

116 print(api.markdown_list(DB['handle'], query_text, list_type='ol')) 

117 else: 

118 print(api.markdown_list(DB['handle'], query_text, list_type='ol', data=data)) 

119 

120 

121@no_type_check 

122def ul(query_text: str = '', data=None) -> None: 

123 """Public document interface for unordered list.""" 

124 if data is None: 124 ↛ 125line 124 didn't jump to line 125, because the condition on line 124 was never true

125 if not DB.get('handle', None): 

126 DB['handle'] = api.login() 

127 

128 print(api.markdown_list(DB['handle'], query_text, list_type='ul')) 

129 else: 

130 print(api.markdown_list(DB['handle'], query_text, list_type='ul', data=data)) 

131 

132 

133@no_type_check 

134def hx(level: int, query_text: str = '', data=None) -> None: 

135 """Public document interface for headings 1 through 6.""" 

136 if data is None: 136 ↛ 137line 136 didn't jump to line 137, because the condition on line 136 was never true

137 if not DB.get('handle', None): 

138 DB['handle'] = api.login() 

139 

140 print(api.markdown_heading(DB['handle'], query_text, level=level)) 

141 else: 

142 print(api.markdown_heading(api.Jira(''), query_text, level=level, data=data)) 

143 

144 

145@no_type_check 

146def h1(query_text: str = '', data=None) -> None: 

147 """Public document interface for heading 1.""" 

148 return hx(1, query_text, data) 

149 

150 

151@no_type_check 

152def h2(query_text: str = '', data=None) -> None: 

153 """Public document interface for heading 2.""" 

154 return hx(2, query_text, data) 

155 

156 

157@no_type_check 

158def h3(query_text: str = '', data=None) -> None: 

159 """Public document interface for heading 3.""" 

160 return hx(3, query_text, data) 

161 

162 

163@no_type_check 

164def h4(query_text: str = '', data=None) -> None: 

165 """Public document interface for heading 4.""" 

166 return hx(4, query_text, data) 

167 

168 

169@no_type_check 

170def h5(query_text: str = '', data=None) -> None: 

171 """Public document interface for heading 5.""" 

172 return hx(5, query_text, data) 

173 

174 

175@no_type_check 

176def h6(query_text: str = '', data=None) -> None: 

177 """Public document interface for heading 6.""" 

178 return hx(6, query_text, data)