def test_get_comment_id(self): """ Test that get_comment_id returns a properly-formatted comment id. """ ref = SubredditSpider(None) # test totally invalid id try: ref.get_comment_id('!-$.') self.fail( "Failed to raise an exception on input of an improperly formatted id." ) except InvalidIdException: pass # test value of wrong type try: ref.get_comment_id('t3_abc123') self.fail( "Failed to raise an exception on input of an id of the wrong type." ) except InvalidIdException: pass # test parsing self.assertEqual(ref.get_comment_id('t1_abc123'), 't1_abc123') self.assertEqual(ref.get_comment_id('abc123'), 't1_abc123')
def test_get_raw_id(self): """ Test that get_raw_id returns a properly-formatted raw base36 id. """ ref = SubredditSpider(None) # test totalli invalid id try: ref.get_raw_id('!-$.') self.fail( "Failed to raise an exception on input of an improperly formatted id." ) except InvalidIdException: pass # test value of invalid type try: ref.get_raw_id('t9_abc123') self.fail( "Failed to raise an exception on input of in invalid type.") except InvalidIdException: pass self.assertEqual(ref.get_raw_id('t8_abc123'), 'abc123') self.assertEqual(ref.get_raw_id('t3_abc123'), 'abc123') self.assertEqual(ref.get_raw_id('abc123'), 'abc123')
def test_get_comment_id(self): """ Test that get_comment_id returns a properly-formatted comment id. """ ref = SubredditSpider(None) # test totally invalid id try: ref.get_comment_id('!-$.') self.fail("Failed to raise an exception on input of an improperly formatted id.") except InvalidIdException: pass # test value of wrong type try: ref.get_comment_id('t3_abc123') self.fail("Failed to raise an exception on input of an id of the wrong type.") except InvalidIdException: pass # test parsing self.assertEqual(ref.get_comment_id('t1_abc123'), 't1_abc123') self.assertEqual(ref.get_comment_id('abc123'), 't1_abc123')
def test_get_raw_id(self): """ Test that get_raw_id returns a properly-formatted raw base36 id. """ ref = SubredditSpider(None) # test totalli invalid id try: ref.get_raw_id('!-$.') self.fail("Failed to raise an exception on input of an improperly formatted id.") except InvalidIdException: pass # test value of invalid type try: ref.get_raw_id('t9_abc123') self.fail("Failed to raise an exception on input of in invalid type.") except InvalidIdException: pass self.assertEqual(ref.get_raw_id('t8_abc123'), 'abc123') self.assertEqual(ref.get_raw_id('t3_abc123'), 'abc123') self.assertEqual(ref.get_raw_id('abc123'), 'abc123')