def testAddCommand_existing(self): # on this one, the user markdown formatting gets altered/standardized slacklib.command_add('*****@*****.**', 'went to the park') t = self._most_recent_snippet('*****@*****.**') expected = textwrap.dedent(""" - went for a walk - sniffed some things - hoping to sniff more things! #yolo - went to the park """).strip() self.assertEqual(expected, t.text) self.assertEquals(True, t.is_markdown)
def testAddCommand_blank(self): # blank slate should be easy... r = slacklib.command_add('*****@*****.**', 'went to the park') t = self._most_recent_snippet('*****@*****.**') self.assertIn("Added *went to the park* to your weekly snippets", r) self.assertEquals('- went to the park', t.text) self.assertEquals(True, t.is_markdown)
def testAddCommand_existingIsMalformed(self): # we should be told we cannot to add to a snippet that is malformed! toby_email = '*****@*****.**' r = slacklib.command_add(toby_email, 'went to the park') self.assertIn("Your snippets are not in a format I understand", r) # ...and the existing snippets should not have been touched t = self._most_recent_snippet(toby_email) self.assertNotIn("went to the park", t.text) self.assertIn("LUNCHTIME SUCKERS!", t.text) self.assertEquals(False, t.is_markdown)
def testAddCommand_unicode(self): r = slacklib.command_add('*****@*****.**', u'i “like” food') t = self._most_recent_snippet('*****@*****.**') self.assertIn('i “like” food', r) self.assertIn('i “like” food', t.text)
def testAddCommand_markupUsernames(self): # usernames should be marked up properly so they get syntax highlighted r = slacklib.command_add('*****@*****.**', 'ate w/ @toby, yay') t = self._most_recent_snippet('*****@*****.**') self.assertIn("ate w/ <@toby>, yay", r) self.assertIn("- ate w/ <@toby>, yay", t.text)
def testAddCommand_noAccount(self): # dont crash horribly if user doesnt exist r = slacklib.command_add('*****@*****.**', 'how is account formed?') self.assertIn("You don't appear to have a snippets account", r)
def testAddCommand_noArgs(self): # we need to handle when they try to add nothing! r = slacklib.command_add('*****@*****.**', '') self.assertIn("*what* do you want me to add exactly?", r)