test_clean.py
797 B · python · 25 lines
1import os2import sys3import unittest45os.environ.setdefault("STATS_BUCKET", "test")6os.environ.setdefault("STATS_FUNCTIONS", "one,two")7os.environ.setdefault("STATS_KEY", "stats.json")8sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))910from handler import clean1112DIRTY = "sync PUT https://api.printful.com/sync/variant/5511431634?api_key=sk_live_9f3 200 Authorization: Bearer shpat_0123 " + "x" * 3001314class Clean(unittest.TestCase):1516 def test_clean_strips_urls_and_credentials_and_clips_to_160(self):17 out = clean(DIRTY)18 self.assertEqual(len(out), 160)19 self.assertIn("<url>", out)20 self.assertNotIn("http", out)21 self.assertNotIn("sk_live_9f3", out)22 self.assertNotIn("shpat_0123", out)2324if __name__ == "__main__":25 unittest.main()