def test__parse_redistogo(self): """Test the internal parser with REDISTOGO_URL""" parsed = _parse(self.redistogo) self.assertEqual(parsed["HOST"], "example.redistogo.com") self.assertEqual(parsed["USER"], "redistogo") self.assertEqual(parsed["PASSWORD"], "password") self.assertEqual(parsed["PORT"], 6379)
def test__parse_localhost(self): """Test the internal parser with localhost""" parsed = _parse(self.localhost) self.assertEqual(parsed["HOST"], "localhost") self.assertTrue(parsed["USER"] is None) self.assertTrue(parsed["PASSWORD"] is None) self.assertTrue(parsed["PORT"] is None)
def test__parse(self): """Test the `_parse()` method""" parsed = _parse('redis://*****:*****@hostname.com:1234/5') self.assertEqual(parsed['HOST'], 'hostname.com') self.assertEqual(parsed['USERNAME'], 'username') self.assertEqual(parsed['PASSWORD'], 'password') self.assertEqual(parsed['PORT'], 1234) self.assertEqual(parsed['DB'], 5)