from django.test import TestCase from jarvis.core.models import Citation, Email import markdown class CitationModelTests(TestCase): def test_citation_str(self): """Test the __str__ method to ensure it returns the correct string representation of a Citation instance.""" citation = Citation( quote="Be yourself; everyone else is already taken.", author="Oscar Wilde" ) citation.save() expected_str = "Be yourself; everyone else is already taken. - Oscar Wilde" self.assertEqual(str(citation), expected_str, "The __str__ method does not return the expected string.") def test_to_markdown(self): """Test the to_markdown method to ensure it correctly converts the quote to Markdown.""" citation = Citation( quote="**Bold** text and _italic_ text." ) citation.save() expected_markdown = markdown.markdown(citation.quote) self.assertEqual(citation.to_markdown(), expected_markdown, "The to_markdown method does not return the expected Markdown string.") class EmailModelTests(TestCase): def test_email_str(self): """Test the __str__ method to ensure it returns the correct string representation of an Email instance.""" email = Email( title="Meeting Reminder", receivers="john@example.com, jane@example.com" ) email.save() expected_str = "`Meeting Reminder` sent to john@example.com, jane@example.com" self.assertEqual(str(email), expected_str, "The __str__ method does not return the expected string.")