Source

Fat x Fast / tests / scenemanager_test.py

Full commit
from FatxFast import game
from FatxFast.scenes import scenemanager
from FatxFast.scenes import gamescene
from FatxFast.scenes import menuscenes
import pygame
from nose.tools import *

class TestManager(object):
    
    def setup(self):
        self.game = game.Game()
        self.manager = scenemanager.SceneManager(self.game)

    def test_change_scene(self):
        # Test by string change
        self.manager.change_scene("gamescene")
        assert_is_instance(self.manager.get_scene(), gamescene.GameScene)
        # Test by object change
        self.manager.change_scene(menuscenes.ExitScene(self.manager))
        assert_is_instance(self.manager.get_scene(), menuscenes.ExitScene)

    def test_change_scene_to_gamescene(self):
        self.manager.change_scene("gamescene")
        assert_equal(len(self.manager.scenes), 1)
        assert_equal(self.manager.get_scene().paused, False)

    def test_push_scene(self):
        # Test push by string
        self.manager.push_scene("gamescene")
        assert_is_instance(self.manager.get_scene(), gamescene.GameScene)
        # Test push by object
        self.manager.push_scene(menuscenes.ExitScene(self.manager))
        assert_is_instance(self.manager.get_scene(), menuscenes.ExitScene)

    def test_resuming_game(self):
        self.manager.change_scene("gamescene")
        self.manager.push_scene("savescene")
        self.manager.pop_scene()
        assert_not_equal(self.manager.get_scene().paused, True)

    def test_pop_scene(self):
        scene_count = len(self.manager.scenes)
        self.manager.pop_scene()
        assert_less(len(self.manager.scenes), scene_count)