def test_simple_formation(self): datelink = DateLink( date=self.epoch, date_format="{date_long}", fallback=f"{self.epoch}" ) self.assertEqual( f"{datelink}", f"<!date^{self.epoch}^{{date_long}}|{self.epoch}>" )
def test_with_url(self): datelink = DateLink( date=self.epoch, date_format="{date_long}", link="http://google.com", fallback=f"{self.epoch}", ) self.assertEqual( f"{datelink}", f"<{self.epoch}^{{date_long}}^http://google.com|{self.epoch}>", )
async def test_date_link_async(self): client = self.async_client link = DateLink( date=datetime.now(), date_format="{date_long} {time}", fallback="fallback string", link="https://www.example.com" ) message=f"Here is a date link: {link}" response = await client.chat_postMessage(channel=self.channel_id, text=message) self.assertIsNotNone(response) self.assertRegexpMatches(response["message"]["text"], r"Here is a date link: <!date^\d+^{date_long} {time}^https://www.example.com|fallback string>")