]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - regression-tests.api/test_Cache.py
Merge pull request #8795 from omoerbeek/rec-lua-docs-policytag
[thirdparty/pdns.git] / regression-tests.api / test_Cache.py
index 6a3f618d51cf84686dafbeb5c83590009be2faf1..546864e325ec57e7252a7db4a1e4fe086599c6ea 100644 (file)
@@ -1,4 +1,5 @@
-from test_helper import ApiTestCase, is_auth, is_recursor
+from test_helper import ApiTestCase, is_auth, is_recursor, sdig
+import unittest
 
 
 class Servers(ApiTestCase):
@@ -9,6 +10,30 @@ class Servers(ApiTestCase):
         data = r.json()
         self.assertIn('count', data)
 
+    @unittest.skipIf(not is_recursor(), "Not applicable")
+    def test_flush_count(self):
+        sdig("ns1.example.com", 'A')
+        r = self.session.put(self.url("/api/v1/servers/localhost/cache/flush?domain=ns1.example.com."))
+        self.assert_success_json(r)
+        data = r.json()
+        self.assertIn('count', data)
+        self.assertEquals(1, data['count'])
+
+    @unittest.skipIf(not is_recursor(), "Not applicable")
+    def test_flush_subtree(self):
+        sdig("ns1.example.com", 'A')
+        sdig("ns2.example.com", 'A')
+        r = self.session.put(self.url("/api/v1/servers/localhost/cache/flush?domain=example.com.&subtree=false"))
+        self.assert_success_json(r)
+        data = r.json()
+        self.assertIn('count', data)
+        self.assertEquals(1, data['count'])
+        r = self.session.put(self.url("/api/v1/servers/localhost/cache/flush?domain=example.com.&subtree=true"))
+        self.assert_success_json(r)
+        data = r.json()
+        self.assertIn('count', data)
+        self.assertEquals(2, data['count'])
+
     def test_flush_root(self):
         r = self.session.put(self.url("/api/v1/servers/localhost/cache/flush?domain=."))
         self.assert_success_json(r)