summaryrefslogtreecommitdiff
path: root/tests/test_screens.py
blob: cd827d37a15a2fe06f3a23807d5dbc0a1beaa58f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
import unittest

from pathlib import Path

from sliceitoff.text import fonts, TextPage

from sliceitoff.screens import (
    gameover_screen,
    hiscores_screen,
    initials_screen,
    instructions1_screen,
    instructions2_screen,
    level_screen,
    levelup_screen,
    mainmenu_screen,
    settings_screen)

class TestScreens(unittest.TestCase):
    def setUp(self):
        fonts.init( Path(__file__).parent.parent.resolve()
                .joinpath('src').joinpath('sliceitoff').joinpath('assets'))

    def test_can_run_gameover(self):
        page = gameover_screen()
        self.assertEqual(TextPage, type(page))

    def test_can_run_hiscores(self):
        page = hiscores_screen("just text")
        self.assertEqual(TextPage, type(page))

    def test_can_run_initials(self):
        page = initials_screen("VIL")
        self.assertEqual(TextPage, type(page))

    def test_can_run_instructions1(self):
        page = instructions1_screen()
        self.assertEqual(TextPage, type(page))

    def test_can_run_instructions2(self):
        page = instructions2_screen()
        self.assertEqual(TextPage, type(page))

    def test_can_run_level(self):
        page = level_screen(2)
        self.assertEqual(TextPage, type(page))

    def test_can_run_levelup(self):
        class mock_stats:
            def __init__(self):
                self.level = 1
                self.enemies = 2
                self.field_count = 3
                self.lives = 4
                self.bonus = 5
                self.percent = 5
            def calc_bonus(self):
                return (1,2,3,4,5,6)
        page = levelup_screen(stats=mock_stats())
        self.assertEqual(TextPage, type(page))

    def test_can_run_mainmenu(self):
        page = mainmenu_screen(2)
        self.assertEqual(TextPage, type(page))

    def test_can_run_settings(self):
        page = settings_screen(2)
        self.assertEqual(TextPage, type(page))