Exemple #1
0
    def test_wrong_input(self, *args):
        bs_tmp = bowling_module.BowlingScore()
        score, frameCount, textOutput = bs_tmp.calculateScore(-1)

        assert frameCount == 1
        assert textOutput == 'Error, 1 < score < 10'
        assert score == 0
Exemple #2
0
    def test_strike(self, *args):
        """ test strike
        """

        bs_tmp = bowling_module.BowlingScore()
        score, frameCount, textOutput = bs_tmp.calculateScore(10)

        assert score == 10
        assert frameCount == 2
        assert textOutput == 'Strike!'
Exemple #3
0
    def test_simpleExample(self, *args):
        """ test basic example
        """

        bs_tmp = bowling_module.BowlingScore()
        score, frameCount, textOutput = bs_tmp.calculateScore(5)

        assert score == 5
        assert frameCount == 1
        assert textOutput == 'Normal score'
Exemple #4
0
    def test_sum_error(self, *args):
        bs_tmp = bowling_module.BowlingScore()

        score, frameCount, textOutput = bs_tmp.calculateScore(5)
        assert score == 5
        assert frameCount == 1
        assert textOutput == 'Normal score'

        score, frameCount, textOutput = bs_tmp.calculateScore(6)
        assert score == 5
        assert frameCount == 1
        assert textOutput == 'Score to high! Try again!'
Exemple #5
0
    def test_spare(self, *args):
        bs_tmp = bowling_module.BowlingScore()

        score, frameCount, textOutput = bs_tmp.calculateScore(1)
        assert score == 1
        assert frameCount == 1
        assert textOutput == 'Normal score'

        score, frameCount, textOutput = bs_tmp.calculateScore(9)
        assert score == 10
        assert frameCount == 2
        assert textOutput == 'Spare!'
Exemple #6
0
    def test_string_error(self, *args):
        bs_tmp = bowling_module.BowlingScore()

        # with pytest.raises(Exception):
        score, frameCount, textOutput = bs_tmp.calculateScore('foo')

        assert score == 0
        assert frameCount == 1

        # and continues healthy after wrong input
        score, frameCount, textOutput = bs_tmp.calculateScore(3)

        assert score == 3
        assert frameCount == 1
Exemple #7
0
    def __init__(self, parent, *args):
        tk.Frame.__init__(self, parent, *args)
        self.parent = parent
        self.frameCount = 1
        self.score = 0
        self.frameCountText = tk.StringVar()
        self.scoreText = tk.StringVar()
        self.textMessage = tk.StringVar()
        self.setScore()
        self.setFrameCount()
        self.bs = bowling_module.BowlingScore()

        self.parent.geometry("300x200")
        self.parent.title("Calculate bowling score")

        self.addWindowElements()
Exemple #8
0
#!/usr/bin/env python3

from backend import bowling_module
import pytest

bs_simple_example = bowling_module.BowlingScore()
bs_highest_score = bowling_module.BowlingScore()
bs_specific_example = bowling_module.BowlingScore()


class Test_single_scores:
    """ test output values depending on input
    """
    def test_simpleExample(self, *args):
        """ test basic example
        """

        bs_tmp = bowling_module.BowlingScore()
        score, frameCount, textOutput = bs_tmp.calculateScore(5)

        assert score == 5
        assert frameCount == 1
        assert textOutput == 'Normal score'

    def test_strike(self, *args):
        """ test strike
        """

        bs_tmp = bowling_module.BowlingScore()
        score, frameCount, textOutput = bs_tmp.calculateScore(10)