def test_purge_args(self, stderr): _, _, path = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', '/foo/bar']) self.assertEqual(path, '/foo/bar') _, _, path = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', '/foo/bar?a=b&c=d']) self.assertEqual(path, '/foo/bar?a=b&c=d') _, _, path = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', 'http://www.example.com/']) self.assertEqual(path, '/') _, _, path = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', 'www.example.com/']) self.assertEqual(path, 'www.example.com/') with self.assertRaises(SystemExit) as cm: _, _, path = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', 'http://www.example.com']) exc = cm.exception self.assertEqual(2, exc.code) stderr.write.assert_called_with('purge: path is required for purge location\n')
def test_purge_args(self, stderr): _, _, path, _ = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', '/foo/bar']) self.assertEqual(path, '/foo/bar') _, _, path, _ = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', '/foo/bar?a=b&c=d']) self.assertEqual(path, '/foo/bar?a=b&c=d') _, _, path, preserve_path = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', 'http://www.example.com/']) self.assertFalse(preserve_path) self.assertEqual(path, '/') _, _, path, preserve_path = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', 'http://www.example.com/?a=b', '-p']) self.assertTrue(preserve_path) self.assertEqual(path, 'http://www.example.com/?a=b') _, _, path, preserve_path = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', 'http://www.example.com/']) self.assertFalse(preserve_path) self.assertEqual(path, '/') _, _, path, _ = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', 'www.example.com/']) self.assertEqual(path, 'www.example.com/') with self.assertRaises(SystemExit) as cm: _, _, path, _ = plugin.get_purge_args(['-s', 'myservice', '-i', 'myinst', '-l', 'http://www.example.com']) exc = cm.exception self.assertEqual(2, exc.code) stderr.write.assert_called_with('purge: path is required for purge location\n')