def test_pgp_key_link(self): self.assertEqual(pgp_key_link(""), "Unknown") pgp_key = '423423fD9004FB063E2C81117BFB1108D234DAFZ' output = pgp_key_link(pgp_key) self.assertIn(pgp_key, output) self.assertIn("https", output) output = pgp_key_link(pgp_key, "test") self.assertIn("test", output) self.assertIn("https", output) # Numeric key_id <= 8 self.assert_pgp_key_link('0x0023BDC7') # Numeric key_id <= 16 self.assert_pgp_key_link('0xBDC7FF5E34A12F') # Numeric key_id <= 40 self.assert_pgp_key_link('0xA10E234343EA8BDC7FF5E34A12F') pgp_key = '423423fD9004FB063E2C81117BFB1108D234DAFZ' server = getattr(settings, 'PGP_SERVER') with self.settings(PGP_SERVER=''): self.assertNotIn(server, pgp_key_link(pgp_key)) with self.settings(PGP_SERVER_SECURE=False): pgp_key = '423423fD9004FB063E2C81117BFB1108D234DAFZ' self.assertNotIn("https", pgp_key_link(pgp_key))
def test_pgp_key_link(settings): assert pgp_key_link("") == "Unknown" pgp_key = '423423fD9004FB063E2C81117BFB1108D234DAFZ' output = pgp_key_link(pgp_key) assert pgp_key in output assert "https" in output output = pgp_key_link(pgp_key, "test") assert "test" in output assert "https" in output # Numeric key_id <= 8 assert_pgp_key_link('0x0023BDC7') # Numeric key_id <= 16 assert_pgp_key_link('0xBDC7FF5E34A12F') # Numeric key_id <= 40 assert_pgp_key_link('0xA10E234343EA8BDC7FF5E34A12F') pgp_key = '423423fD9004FB063E2C81117BFB1108D234DAFZ' server = getattr(settings, 'PGP_SERVER') settings.PGP_SERVER = '' assert server not in pgp_key_link(pgp_key) settings.PGP_SERVER_SECURE = False pgp_key = '423423fD9004FB063E2C81117BFB1108D234DAFZ' assert "https" not in pgp_key_link(pgp_key)
def assert_pgp_key_link(self, pgp_key): output = pgp_key_link(int(pgp_key, 16)) self.assertIn(pgp_key[2:], output) self.assertIn("https", output)
def pgp_key_link(key_id, link_text=None): return pgp.pgp_key_link(key_id, link_text)
def pgp_key_link(key_id, link_text=None): return pgp.pgp_key_link(key_id, link_text)
def assert_pgp_key_link(pgp_key): output = pgp_key_link(int(pgp_key, 16)) assert pgp_key[2:] in output assert "https" in output