Exemple #1
0
    def testExtractBackgroundExistingTeam(self):
        """Test extract background for an existing team"""

        # some date to use through out test
        league_name = "TTIEB Non-existent league"
        sponsor_name = "TTIEB Non-existent sponsor"
        color = "Some Color"
        sponsor = self.add_sponsor(sponsor_name)
        league = self.add_league(league_name)
        team = self.add_team(color, sponsor, league, date.today().year)
        captain = "TTIEB Non-existent player"
        background = {
            'sponsor': sponsor_name,
            'color': color,
            'captain': captain,
            'league': league_name
        }

        # extract the background
        result = extract_background(background)

        # make sure the values match what was given
        self.assertEqual(result['sponsor']['sponsor_name'], sponsor_name,
                         "Extracted wrong sponsor")
        self.assertEqual(result['league']['league_name'], league_name,
                         "Extracted wrong league")
        self.assertEqual(result['team']['color'], color,
                         "Extracted wrong color")
        self.assertEqual(result['team']['team_id'], team["team_id"],
                         "Extracted wrong existing team")
        self.assertEqual(result['captain']['player_name'], captain,
                         "Extract wrong captain")
Exemple #2
0
    def testExtractBackgroundNewTeam(self):
        """Test extract background for a new team"""

        # some date to use through out test
        league = "TTIEB Non-existent league"
        sponsor = "TTIEB Non-existent sponsor"
        self.add_sponsor(sponsor)
        self.add_league(league)
        color = "Some Color"
        captain = "TTIEB Non-existent player"
        background = {
            'sponsor': sponsor,
            'color': color,
            'captain': captain,
            'league': league
        }

        # extract the background
        result = extract_background(background)

        # make sure the values match what was given
        self.assertEqual(result['sponsor']['sponsor_name'], sponsor,
                         "Extracted wrong sponsor")
        self.assertEqual(result['league']['league_name'], league,
                         "Extracted wrong league")
        self.assertEqual(result['team']['color'], color,
                         "Extracted wrong color")
        self.assertEqual(result['captain']['player_name'], captain,
                         "Extract wrong captain")
Exemple #3
0
    def testExtractBackgroundCantFindLeague(self):
        """ Test extract background when cant find league"""

        # some date to use through out test
        league = "TTIEB Non-existent league"
        sponsor = "TTIEB Non-existent sponsor"
        self.add_sponsor(sponsor)
        color = "Some Color"
        captain = "TTIEB Non-existent player"
        background = {
            'sponsor': sponsor,
            'color': color,
            'captain': captain,
            'league': league
        }
        try:
            extract_background(background)
            self.assertTrue(False, "Expecting exception raised")
        except LeagueDoesNotExist:
            pass
Exemple #4
0
    def testExtractBackgroundErrors(self):
        """Test that errors are raised for incomplete background """

        # some date to use through out test
        sponsor = "TTIEB Non-existent sponsor"
        color = "Some Color"
        captain = "TTIEB Non-existent player"
        league = "TTIEB Non-existent league"

        # missing background values
        try:
            extract_background({})
            self.assertTrue(False, "Expecting exception raised")
        except InvalidField:
            pass

        # given league example
        background = {
            'sponsor': sponsor,
            'color': color,
            'captain': captain,
            'league': "ex. League Example"
        }
        try:
            extract_background(background)
            self.assertTrue(False, "Expecting exception raised")
        except InvalidField:
            pass

        # given captain example
        background = {
            'sponsor': sponsor,
            'color': color,
            'captain': "ex. captain",
            'league': league
        }
        try:
            extract_background(background)
            self.assertTrue(False, "Expecting exception raised")
        except InvalidField:
            pass

        # given color example
        background = {
            'sponsor': sponsor,
            'color': "ex. color",
            'captain': captain,
            'league': league
        }
        try:
            extract_background(background)
            self.assertTrue(False, "Expecting exception raised")
        except InvalidField:
            pass

        # given sponsor example
        background = {
            'sponsor': sponsor,
            'color': "ex. color",
            'captain': captain,
            'league': league
        }
        try:
            extract_background(background)
            self.assertTrue(False, "Expecting exception raised")
        except InvalidField:
            pass