Exemplo n.º 1
0
    def test_create_linked_list(self):
        ''' Tests create_linked_list(fencers_csv). '''
        LL_of_24 = create_linked_list('csv_files/MEconflicts.csv')
        self.assertTrue(isinstance(LL_of_24, Linked_List),
                        'Creates a LL instance.')
        self.assertTrue(isinstance(LL_of_24.head, Node),
                        'Creates a LL containing Nodes.')
        self.assertEqual(LL_of_24.length, 24, 'Creates a LL of proper length.')

        LL_of_13 = create_linked_list('csv_files/MEshort.csv')
        self.assertEqual(LL_of_13.length, 13, 'Creates a LL of proper length.')
Exemplo n.º 2
0
    def test_determine_num_pools(self):
        ''' Tests determine_num_pools(linked_list). '''
        LL_of_24 = create_linked_list('csv_files/MEconflicts.csv')
        self.assertEqual(
            determine_num_pools(LL_of_24), 4,
            'Should return the correct number of pools given a LL of 24.')

        LL_of_13 = create_linked_list('csv_files/MEshort.csv')
        self.assertEqual(
            determine_num_pools(LL_of_13), 2,
            'Should return the correct number of pools given a LL of 13.')

        LL_of_48 = create_linked_list('csv_files/MEentries.csv')
        self.assertEqual(
            determine_num_pools(LL_of_48), 8,
            'Should return the correct number of pools given a LL of 48.')
Exemplo n.º 3
0
 def test_create_init_pools(self):
     '''Tests create_init_pools(linked_list). '''
     LL_of_24 = create_linked_list('csv_files/MEconflicts.csv')
     init_pools = create_init_pools(LL_of_24)
     self.assertEqual(len(init_pools), 4,
                      'Creates the right amount of pools.')
     self.assertDictEqual(
         init_pools[0][0], {
             'first_name': ' Alexander',
             'last_name': 'TUROFF',
             'rank': 'A15',
             'team': 'FISHKILL / CANDLE '
         }, 'The first index of pool 1 is correct.')
     self.assertDictEqual(
         init_pools[1][0], {
             'first_name': ' Tracy',
             'last_name': 'COLWELL',
             'rank': 'A15',
             'team': 'EBFG '
         }, 'Correctly adds the next ranked player to the next pool.')
     self.assertDictEqual(
         init_pools[3][0], {
             'first_name': ' David',
             'last_name': 'HITCHCOCK',
             'rank': 'A15',
             'team': 'NO FEAR '
         }, 'The last index of the pre-serpentine turn is correct.')
     self.assertDictEqual(
         init_pools[3][1], {
             'first_name': ' Mehmet',
             'last_name': 'TEPEDELENLIOGLU',
             'rank': 'A15',
             'team': 'EBFG '
         }, 'The first index of the post-serpentine turn is correct.')
     self.assertDictEqual(
         init_pools[2][1], {
             'first_name': ' Alexandre',
             'last_name': 'RACHTCHININE',
             'rank': 'A15',
             'team': 'NO FEAR'
         }, 'The second index of the post-serpentine turn is correct.')
     self.assertDictEqual(
         init_pools[0][2], {
             'first_name': ' Joseph',
             'last_name': 'DEUCHER',
             'rank': 'A14',
             'team': ''
         }, 'The third index of the 2nd post-serpentine turn is correct.')
     self.assertDictEqual(
         init_pools[1][2], {
             'first_name': ' Kashi',
             'last_name': 'WAY',
             'rank': 'A14',
             'team': 'EBFG '
         }, 'The third index of the 2nd post-serpentine turn is correct.')
Exemplo n.º 4
0
import sys
import csv
from linked_list import Node, Linked_List
from model import create_linked_list, determine_num_pools, create_init_pools

LL = create_linked_list()
num_pools = determine_num_pools(LL)
create_init_pools(LL, num_pools)
Exemplo n.º 5
0
import sys
from model import create_linked_list, create_init_pools, sort_pools, print_pools, check_length

# Create a linked list of players
LL = create_linked_list(sys.argv[1])

# Check number of players
check_length(LL)

# Use LL to create initial pools
init_pools = create_init_pools(LL)

# Sort initial pools
sorted_pools = sort_pools(init_pools, LL)

# print pools
print_pools(sorted_pools)