<commit_before>import os.path
import unittest.mock as mock

from tests.plugins import PluginTestCase
import plugins.weather


f = 'plugins.weather.get_owm_json'


def get_json(state):
	path = os.path.join(
		os.path.dirname(os.path.dirname(__file__)),
		'files', 'openweathermap_'+state+'.json'
	)
	with open(path, 'r') as f:
		return f.read()


class WeatherPluginTest(PluginTestCase):
	def create_plugin(self):
		return plugins.weather.WeatherPlugin(self.bot, self.channel)

	@mock.patch(f, return_value=get_json('edinburgh'))
	def test_cmd_simple(self, mock):
		ret = self.cmd('weather edinburgh')
		self.assertEqual('Weather in Edinburgh, GB: Rain - the temperature is 17.64°C', ret)

	@mock.patch(f, return_value=get_json('tel_aviv'))
	def test_cmd_multiword_city(self, mock):
		ret = self.cmd('weather tel aviv')
		self.assertEqual('Weather in Tel Aviv District, IL: Clouds - the temperature is 33.11°C', ret)

	@mock.patch(f, return_value=get_json('404'))
	def test_not_found(self, mock):
		ret = self.cmd('weather asljkhajkhf')<commit_msg>fix tests<commit_after>import os.path
import unittest.mock as mock

from tests.plugins import PluginTestCase
import plugins.weather


f = 'plugins.weather.get_owm_json'


def get_json(state):
	path = os.path.join(
		os.path.dirname(os.path.dirname(__file__)),
		'files', 'openweathermap_'+state+'.json'
	)
	with open(path, 'r') as f:
		return f.read()


class WeatherPluginTest(PluginTestCase):
	def create_plugin(self):
		return plugins.weather.WeatherPlugin(self.bot, self.channel)

	@mock.patch(f, return_value=get_json('edinburgh'))
	def test_cmd_simple(self, mock):
		ret = self.cmd('weather edinburgh')
		self.assertEqual('Weather in Edinburgh, GB: light rain - temperature: 17.64°C', ret)

	@mock.patch(f, return_value=get_json('tel_aviv'))
	def test_cmd_multiword_city(self, mock):
		ret = self.cmd('weather tel aviv')
		self.assertEqual('Weather in Tel Aviv District, IL: few clouds - temperature: 33.11°C', ret)

	@mock.patch(f, return_value=get_json('404'))
	def test_not_found(self, mock):
		ret = self.cmd('weather asljkhajkhf')
{'fraction_non_alphanumeric': 0.13793103448275862, 'fraction_numerical': 0.01053639846743295, 'mean_word_length': 5.6528662420382165, 'pattern_counts': {'":': 0, '<': 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': '7563452', 'n_tokens_mistral': 795, 'n_tokens_neox': 726, 'n_words': 162}