def test_time(self): assert isinstance(EorzeaTime.now().minute, int) assert isinstance(EorzeaTime.now().hour, int) test_time = ((13, 1, 10, 50), (12, 35, 10, 50), (12, 1, 25, 50), (12, 1, 10, 61)) with pytest.raises(ValueError): for t in test_time: M, S, h, m = t EorzeaTime(M, S, h, m) with pytest.raises(TypeError): EorzeaTime("kappa", 1, 10, 50)
async def on_message(self, msg): if not msg.author.bot: if msg.content.startswith('!4'): command = msg.content.split(' ') if command[1] == 'weather': etl = EorzeaTime.next_weather_period_start() try: island = self.island_list[command[2]] except KeyError as err: island = None print(repr(err)) results = [] if not island: return for time in etl: from_ = dt.fromtimestamp(time, tz=self.tw).strftime("%H:%M") weather = EorzeaWeather.forecast_weather( island, time).lower().replace(" ", "_") icon_id = discord.utils.find( lambda e: e.name == weather, msg.server.emojis).id result = '<:{}:{}> `{}~`'.format( weather, icon_id, from_) results.append(result) weather_transform = "\n".join(str(r) for r in results) await self.send_message(msg.channel, weather_transform)
def test_field(self): for t in (EorzeaTime.weather_period(10)): weather = EorzeaWeather.forecast('Eureka Pyros', t) assert isinstance(weather, str) with pytest.raises(KeyError): pyros_weather = EorzeaWeather.forecast('EuPyros', 1542591400.045)
def test_field(self): weathers = EorzeaWeather.forecast('Eureka Pyros', EorzeaTime.weather_period(10)) for weather in weathers: assert isinstance(weather, str) with pytest.raises(ValueError): pyros_weather = EorzeaWeather.forecast('EuPyros', 1542591400.045)
def test_step(self): timelist = [t for t in EorzeaTime.weather_period(10)] assert len(timelist) is 10