#coding=utf-8
from __future__ import absolute_import
import unittest
import threading
import random
import tkinter as tk
from pip_tkinter.utils import MultiItemsList
[docs]class TestMultiItemsList(unittest.TestCase):
"""
Test the GUI application and it's different GUI events
"""
[docs] def setUp(self):
self.root = tk.Tk()
self.root.withdraw()
#Create list of headers
self.headers = ['A', 'B', 'C']
self.multi_items_list = MultiItemsList(self.root, self.headers)
self.number_of_elements = 8 + random.randrange(15)
#Create a result tuple for testing multi_items_list
results_tuple = []
for i in range(self.number_of_elements):
results_tuple.append(('X'+str(i), 'Y'+str(i), 'Z'+str(i)))
self.multi_items_list.populate_rows(results_tuple)
#Get Id of all elements in treeview
self.iid_tuple = self.multi_items_list.scroll_tree.get_children()
[docs] def test_only_single_selection_is_allowed(self):
check_browse_option = self.multi_items_list.scroll_tree['selectmode']
self.assertEqual(str(check_browse_option),'browse')
[docs] def test_number_of_elements_in_tree_view(self):
self.assertEqual(self.number_of_elements, len(self.iid_tuple))
[docs] def tearDown(self):
self.root.destroy()
del self.root