1+ """Test assignee functionality added to issue metrics."""
2+
3+ import os
4+ import unittest
5+ from unittest .mock import patch
6+ from markdown_writer import get_non_hidden_columns
7+
8+
9+ class TestAssigneeFunctionality (unittest .TestCase ):
10+ """Test suite for the assignee functionality."""
11+
12+ @patch .dict (
13+ os .environ ,
14+ {
15+ "GH_TOKEN" : "test_token" ,
16+ "SEARCH_QUERY" : "is:issue is:open repo:user/repo" ,
17+ "HIDE_ASSIGNEE" : "false" ,
18+ "HIDE_AUTHOR" : "false" ,
19+ },
20+ clear = True ,
21+ )
22+ def test_get_non_hidden_columns_includes_assignee_by_default (self ):
23+ """Test that assignee column is included by default."""
24+ columns = get_non_hidden_columns (labels = None )
25+ self .assertIn ("Assignee" , columns )
26+ self .assertIn ("Author" , columns )
27+
28+ @patch .dict (
29+ os .environ ,
30+ {
31+ "GH_TOKEN" : "test_token" ,
32+ "SEARCH_QUERY" : "is:issue is:open repo:user/repo" ,
33+ "HIDE_ASSIGNEE" : "true" ,
34+ "HIDE_AUTHOR" : "false" ,
35+ },
36+ clear = True ,
37+ )
38+ def test_get_non_hidden_columns_hides_assignee_when_env_set (self ):
39+ """Test that assignee column is hidden when HIDE_ASSIGNEE is true."""
40+ columns = get_non_hidden_columns (labels = None )
41+ self .assertNotIn ("Assignee" , columns )
42+ self .assertIn ("Author" , columns )
43+
44+ @patch .dict (
45+ os .environ ,
46+ {
47+ "GH_TOKEN" : "test_token" ,
48+ "SEARCH_QUERY" : "is:issue is:open repo:user/repo" ,
49+ "HIDE_ASSIGNEE" : "false" ,
50+ "HIDE_AUTHOR" : "true" ,
51+ },
52+ clear = True ,
53+ )
54+ def test_get_non_hidden_columns_shows_assignee_but_hides_author (self ):
55+ """Test that assignee can be shown while author is hidden."""
56+ columns = get_non_hidden_columns (labels = None )
57+ self .assertIn ("Assignee" , columns )
58+ self .assertNotIn ("Author" , columns )
59+
60+ @patch .dict (
61+ os .environ ,
62+ {
63+ "GH_TOKEN" : "test_token" ,
64+ "SEARCH_QUERY" : "is:issue is:open repo:user/repo" ,
65+ "HIDE_ASSIGNEE" : "true" ,
66+ "HIDE_AUTHOR" : "true" ,
67+ },
68+ clear = True ,
69+ )
70+ def test_get_non_hidden_columns_hides_both_assignee_and_author (self ):
71+ """Test that both assignee and author can be hidden."""
72+ columns = get_non_hidden_columns (labels = None )
73+ self .assertNotIn ("Assignee" , columns )
74+ self .assertNotIn ("Author" , columns )
75+
76+ def test_assignee_column_position (self ):
77+ """Test that assignee column appears before author column."""
78+ with patch .dict (
79+ os .environ ,
80+ {
81+ "GH_TOKEN" : "test_token" ,
82+ "SEARCH_QUERY" : "is:issue is:open repo:user/repo" ,
83+ "HIDE_ASSIGNEE" : "false" ,
84+ "HIDE_AUTHOR" : "false" ,
85+ },
86+ clear = True ,
87+ ):
88+ columns = get_non_hidden_columns (labels = None )
89+ assignee_index = columns .index ("Assignee" )
90+ author_index = columns .index ("Author" )
91+ self .assertLess (assignee_index , author_index ,
92+ "Assignee column should appear before Author column" )
93+
94+
95+ if __name__ == "__main__" :
96+ unittest .main ()
0 commit comments