def process_files(self):
        ##
        ## ensure the user has selected a hub map file before proceeding
        if not self.hub_map_file.get():
            print("No directory file selected")
            return
        else:
            hub_map_file = self.hub_map_path + '/' + self.hub_map_file.get()
            errata_file = self.hub_map_path + '/' + self.errata_file.get()
        ##
        ## ensure the user has selected a directory file before proceeding
        if not self.directory_file.get():
            print("No directory file selected")
            return
        else:
            directory_file = self.directory_path + '/' + self.directory_file.get(
            )
        ##
        ## ensure the user has selected a roster file before proceeding
        if not self.roster_file.get():
            print("No roster file selected")
            return
        else:
            roster_file = self.roster_path + '/' + self.roster_file.get()
        ##
        ## process the files
        self.hub_map = hub_map_tools.ReadHubMapFromFile(file_name=hub_map_file)
        print('Hub map file read complete:  ' + hub_map_file)

        self.directory = directory_tools.ReadDirectoryFromFile(
            file_name=directory_file, hub_map=self.hub_map)
        print('Directory file read complete:  ' + directory_file)

        rosterC = roster.Roster(show_errors='', file_name=errata_file)
        self.roster = roster_tools.ReadRosterFromFile(file_name=roster_file,
                                                      hub_map=self.hub_map,
                                                      rosterC=rosterC)
        print('Roster file read complete:  ' + roster_file)
        ##
        ## now that input files have been read, display the buttons to process them
        self.create_user_selection_widgets()
import unittest
from unittest.mock import patch
import os
import roster_tools
import hub_map_tools
import roster

data_file_path = os.path.abspath("./roster_tools_tests/")
hub_file_name = data_file_path + "/hub_map.csv"
common_hub_map = hub_map_tools.ReadHubMapFromFile(hub_file_name)


class UT_01_ReadRosterFromFile(unittest.TestCase):
    def GetResultsUsingInputFile(self, file_name):
        with patch('builtins.input', side_effect=[None]):
            common_roster = roster.Roster()
        roster_file_name = data_file_path + '/' + file_name
        return roster_tools.ReadRosterFromFile(roster_file_name,
                                               common_hub_map, common_roster)

    def test_01_simple(self):
        result = self.GetResultsUsingInputFile(file_name='test_1_simple.xlsx')
        self.assertEqual(2, len(result))
        self.assertEqual(2, len(result[0].adults))
        self.assertEqual(1, len(result[0].children))
        self.assertEqual(2, len(result[1].adults))
        self.assertEqual(8, len(result[1].children))

    def test_02_four_fields(self):
        result = self.GetResultsUsingInputFile(
            file_name='test_2_four_fields.xlsx')
Пример #3
0
 def test_3_duplicate(self):
     file_name = data_file_path + "/test_3_duplicate.csv"
     result = hub_map_tools.ReadHubMapFromFile(file_name)
     self.assertEqual(2, len(result))
Пример #4
0
 def test_2_1_field(self):
     file_name = data_file_path + "/test_2_1_field.csv"
     result = hub_map_tools.ReadHubMapFromFile(file_name)
     self.assertEqual(2, len(result))
Пример #5
0
 def test_1_simple(self):
     file_name = data_file_path + "/test_1_simple.csv"
     result = hub_map_tools.ReadHubMapFromFile(file_name)
     self.assertEqual(3, len(result))
Пример #6
0
import unittest
import os
import hub_map_tools

data_file_path = os.path.abspath("./hub_map_tools_tests/")
map_d = hub_map_tools.ReadHubMapFromFile(data_file_path + "/hub_map.csv")


class UT_ConvertHubStringListToIDList(unittest.TestCase):
    def test_1_one_name(self):
        result = hub_map_tools.ConvertHubStringListToIDList(["First, John"],
                                                            map_d)
        self.assertEqual(["1111"], result)

    def test_2_two_names(self):
        result = hub_map_tools.ConvertHubStringListToIDList(
            ["First, John", "First (Room 1)"], map_d)
        self.assertEqual(["1111", "1111"], result)

    def test_3_hub_not_found(self):
        result = hub_map_tools.ConvertHubStringListToIDList(["Bogus Name"],
                                                            map_d)
        self.assertEqual(["Bogus Name"], result)

    def test_4_1_found_1_not(self):
        result = hub_map_tools.ConvertHubStringListToIDList(
            ["First, John", "Bogus Name"], map_d)
        self.assertEqual(["1111", "Bogus Name"], result)


class UT_ReadRosterFromFile(unittest.TestCase):