def testDelCommand_existingIsMalformed(self): # we should be told we cannot to add to a snippet that is malformed! r = slacklib.command_del('*****@*****.**', ['0']) 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('*****@*****.**') self.assertIn("I had fun", t.text) self.assertEquals(False, t.is_markdown)
def testDelCommand_normalCase(self): r = slacklib.command_del('*****@*****.**', ['1']) t = self._most_recent_snippet('*****@*****.**') self.assertIn( "Removed *sniffed some things* from your weekly snippets", r) expected = textwrap.dedent(""" - went for a walk - hoping to sniff more things! #yolo """).strip() self.assertEqual(expected, t.text) self.assertEquals(True, t.is_markdown)
def testDelCommand_indexNaN(self): r = slacklib.command_del('*****@*****.**', ['one']) self.assertIn("*what* do you want me to delete exactly?", r)
def testDelCommand_nonexistentIndex(self): r1 = slacklib.command_del('*****@*****.**', ['0']) r2 = slacklib.command_del('*****@*****.**', ['4']) expected = "You don't have anything at that index" self.assertIn(expected, r1) self.assertIn(expected, r2)
def testDelCommand_noAccount(self): # dont crash horribly if user doesnt exist r = slacklib.command_del('*****@*****.**', ['1']) self.assertIn("You don't appear to have a snippets account", r)
def testDelCommand_noArgs(self): # we need to handle when they try to add nothing! r = slacklib.command_del('*****@*****.**', []) self.assertIn("*what* do you want me to delete exactly?", r)