Ejemplo n.º 1
0
import config
import bot
import unittest
import time
import psutil
from unittest.mock import Mock
from bot import TimeLimitException


PLAYER_COMMAND = sys.executable + ' test_game.py'
ML_PLAYER_COMMAND = sys.executable + ' test_game2.py'
WRONG_PLAYER_COMMAND = 'fffaaasd test_game.py'
PLAYER_STATE = ''
CONFIG = Mock()
# check 'time_limit' every 'frequency_of_inspection_time' moves
CONFIG.real_time_limit_seconds = 5.0
CONFIG.cpu_time_limit_seconds = 10.0
CONFIG.memory_limit_mb = 15.0
CONFIG.frequency_of_inspection_time = 1000
TIME = CONFIG.real_time_limit_seconds
MEMORY = CONFIG.memory_limit_mb
NORMAL_TIME = TIME / 5


class BotTest(unittest.TestCase):
    def test_create_process(self):
        ''' This test checks if bot process are created correctly. '''
        test_bot = bot.Bot(PLAYER_COMMAND)
        test_bot.create_process()
        self.assertTrue(test_bot._process.is_running())
        test_bot.kill_process()