Пример #1
0
 def print_pairings(self):
     """
     Print out the pairings for first date, along with the combined scores.
     """
     random.seed(0)
     everyone = Match(Profiles(100))
     pairs_list = everyone.pairs()
     for index, (male, female, score) in enumerate(pairs_list):
         print("{:2}: {:2} vs {:2} with the score {:.3f}".format(
             index + 1, male + 1, female + 1, score))
Пример #2
0
"""
Unit tests for match module.
"""
import random
import unittest
from data.profiles import Profiles
from match.match import Match

random.seed(0)
INITIAL_ATTENDANTS = list(Profiles(100))
# Result after matching, RESULTS should be a list of tuples (male_index,female_index, score)
RESULTS = Match(INITIAL_ATTENDANTS)
PAIRS = RESULTS.pairs()


class TestMatch(unittest.TestCase):
    """
    Tests for match. Try to cover as many scenarios as possible, grouping them into different
    methods as appropriate.
    """
    def test_male_female(self):
        """
            Test if pairing is between males and females only
        """
        for couple in PAIRS:
            self.assertNotEqual(INITIAL_ATTENDANTS[couple[0]]["gender"],
                                INITIAL_ATTENDANTS[couple[1]]["gender"])

    def test_50_pairs(self):
        """
            Test if there are exactly 50 pairs