<commit_before># -*- coding: utf-8 -*-
import unittest
import sys
import os
sys.path.append(os.path.realpath(__file__ + "/../../../"))

import tests.common
from tests.output_capturer import capturer


class enterTests(tests.common.common):
	def test_no_place_given_text(self):
		with capturer() as output:
			self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter'])
			self.rpgText._runAction()
		self.assertTrue(output == ['I can\'t enter into nothing'])

	def test_no_place_given_json(self):
		with capturer() as output:
			self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter'])
			self.rpgJSON._runAction()
		self.assertTrue(output == ['{"error": {"message": "I can\'t enter into nothing", "code": 1}}'])

	def test_place_not_available_text(self):
		with capturer() as output:
			self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter', 'cave'])
			self.rpgText._runAction()
		self.assertTrue(output == ['There is no such place here'])

	def test_no_place_given_json(self):
		with capturer() as output:
			self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter', 'cave'])
			self.rpgJSON._runAction()
		self.assertTrue(output == ['{"error": {"message": "There is no such place here", "code": 1}}'])

	def test_wrong_place_text(self):
		with capturer() as output:
			self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter', 'dummyplace'])
			self.rpgText._runAction()
		self.assertTrue(output == ['Unknown place type'])

	def test_wrong_place_given_json(self):
		with capturer() as output:
			self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter', 'dummyplace'])
			self.rpgJSON._runAction()
		self.assertTrue(output == ['{"error": {"message": "Unknown place type", "code": 1}}'])

	def test_when_already_in_text(self):
		self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter', 'dungeon'])
		with capturer() as output:
			self.rpgText._runAction()
		self.rpgText.setAction(['enter', 'dungeon'])
		with capturer() as output:
			self.rpgText._runAction()
		self.assertTrue(output == ['There is no such place here'])

	def test_when_already_in_json(self):
		self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter', 'dungeon'])
		with capturer() as output:
			self.rpgJSON._runAction()
		self.rpgJSON.setAction(['enter', 'dungeon'])
		with capturer() as output:
			self.rpgJSON._runAction()
		self.assertTrue(output == ['{"error": {"message": "There is no such place here", "code": 1}}'])

	def test_text(self):
		with capturer() as output:
			self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter', 'dungeon'])
			self.rpgText._runAction()
		self.assertTrue(output == ['You enter.'])

	def test_json(self):
		with capturer() as output:
			self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', ['enter', 'dungeon'])
			self.rpgJSON._runAction()
		self.assertTrue(output == ['["You enter."]'])

unittest.main()<commit_msg>gettext keys used for the enter command<commit_after># -*- coding: utf-8 -*-
import unittest
import sys
import os
sys.path.append(os.path.realpath(__file__ + "/../../../"))

import tests.common
from tests.output_capturer import capturer
from core.localisation import _


class enterTests(tests.common.common):
	def test_no_place_given_text(self):
		with capturer() as output:
			self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND')])
			self.rpgText._runAction()
		self.assertTrue(output == [_('ERROR_ENTER_NO_PLACE_GIVEN')])

	def test_no_place_given_json(self):
		with capturer() as output:
			self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND')])
			self.rpgJSON._runAction()
		self.assertTrue(output == ['{"error": {"message": "' + _('ERROR_ENTER_NO_PLACE_GIVEN') + '", "code": 1}}'])

	def test_place_not_available_text(self):
		with capturer() as output:
			self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND'), _('PLACE_TYPE_CAVE')])
			self.rpgText._runAction()
		self.assertTrue(output == [_('ERROR_ENTER_PLACE_NOT_AVAILABLE')])

	def test_no_place_given_json(self):
		with capturer() as output:
			self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND'), 'cave'])
			self.rpgJSON._runAction()
		self.assertTrue(output == ['{"error": {"message": "' + _('ERROR_ENTER_PLACE_NOT_AVAILABLE') + '", "code": 1}}'])

	def test_wrong_place_text(self):
		with capturer() as output:
			self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND'), 'dummyplace'])
			self.rpgText._runAction()
		self.assertTrue(output == [_('ERROR_UNKNOWN_PLACE_TYPE')])

	def test_wrong_place_given_json(self):
		with capturer() as output:
			self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND'), 'dummyplace'])
			self.rpgJSON._runAction()
		self.assertTrue(output == ['{"error": {"message": "' + _('ERROR_UNKNOWN_PLACE_TYPE') + '", "code": 1}}'])

	def test_when_already_in_text(self):
		self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND'), _('PLACE_TYPE_DUNGEON')])
		with capturer() as output:
			self.rpgText._runAction()
		self.rpgText.setAction([_('ENTER_COMMAND'), _('PLACE_TYPE_DUNGEON')])
		with capturer() as output:
			self.rpgText._runAction()
		self.assertTrue(output == [_('ERROR_ENTER_PLACE_NOT_AVAILABLE')])

	def test_when_already_in_json(self):
		self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND'), _('PLACE_TYPE_DUNGEON')])
		with capturer() as output:
			self.rpgJSON._runAction()
		self.rpgJSON.setAction([_('ENTER_COMMAND'), _('PLACE_TYPE_DUNGEON')])
		with capturer() as output:
			self.rpgJSON._runAction()
		self.assertTrue(output == ['{"error": {"message": "' + _('ERROR_ENTER_PLACE_NOT_AVAILABLE') + '", "code": 1}}'])

	def test_text(self):
		with capturer() as output:
			self.rpgText.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND'), _('PLACE_TYPE_DUNGEON')])
			self.rpgText._runAction()
		self.assertTrue(output == [_('ENTER_CONFIRMATION')])

	def test_json(self):
		with capturer() as output:
			self.rpgJSON.init(self.dbFile, 'TEST_PLAYER', 'TEST_PLAYER', [_('ENTER_COMMAND'), _('PLACE_TYPE_DUNGEON')])
			self.rpgJSON._runAction()
		self.assertTrue(output == ['["' + _('ENTER_CONFIRMATION') + '"]'])

unittest.main()
{'fraction_non_alphanumeric': 0.17962085308056872, 'fraction_numerical': 0.001579778830963665, 'mean_word_length': 5.8517316017316015, 'pattern_counts': {'":': 24, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6402947', 'n_tokens_mistral': 2464, 'n_tokens_neox': 2305, 'n_words': 416}