From e217824a986eed94c4c534138c15e42d2de779e6 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Fri, 20 Dec 2019 14:40:31 -0500
Subject: [PATCH] Move the leases_current matcher because we have a whole
 module for those ...

---
 src/_zkapauthorizer/tests/matchers.py         | 34 +++++++++++++++++++
 .../tests/test_lease_maintenance.py           | 30 +---------------
 2 files changed, 35 insertions(+), 29 deletions(-)

diff --git a/src/_zkapauthorizer/tests/matchers.py b/src/_zkapauthorizer/tests/matchers.py
index 0a52380..b3730b7 100644
--- a/src/_zkapauthorizer/tests/matchers.py
+++ b/src/_zkapauthorizer/tests/matchers.py
@@ -16,6 +16,10 @@
 Testtools matchers useful for the test suite.
 """
 
+from datetime import (
+    datetime,
+)
+
 import attr
 
 from testtools.matchers import (
@@ -28,6 +32,8 @@ from testtools.matchers import (
     GreaterThan,
     LessThan,
     Equals,
+    AfterPreprocessing,
+    AllMatch,
 )
 
 @attr.s
@@ -99,3 +105,31 @@ def between(low, high):
             LessThan(high),
         ),
     )
+
+
+def leases_current(relevant_storage_indexes, now, min_lease_remaining):
+    """
+    Return a matcher on a ``DummyStorageServer`` instance which matches
+    servers for which the leases on the given storage indexes do not expire
+    before ``min_lease_remaining``.
+    """
+    return AfterPreprocessing(
+        # Get share stats for storage indexes we should have
+        # visited and maintained.
+        lambda storage_server: list(
+            stat
+            for (storage_index, stat)
+            in storage_server.buckets.items()
+            if storage_index in relevant_storage_indexes
+        ),
+        AllMatch(
+            AfterPreprocessing(
+                # Lease expiration for anything visited must be
+                # further in the future than min_lease_remaining,
+                # either because it had time left or because we
+                # renewed it.
+                lambda share_stat: datetime.utcfromtimestamp(share_stat.lease_expiration),
+                GreaterThan(now + min_lease_remaining),
+            ),
+        ),
+    )
diff --git a/src/_zkapauthorizer/tests/test_lease_maintenance.py b/src/_zkapauthorizer/tests/test_lease_maintenance.py
index ddcc6db..c3c7e8b 100644
--- a/src/_zkapauthorizer/tests/test_lease_maintenance.py
+++ b/src/_zkapauthorizer/tests/test_lease_maintenance.py
@@ -37,7 +37,6 @@ from testtools.matchers import (
     HasLength,
     MatchesAll,
     AllMatch,
-    GreaterThan,
     AfterPreprocessing,
 )
 from testtools.twistedsupport import (
@@ -83,6 +82,7 @@ from ..foolscap import (
 from .matchers import (
     Provides,
     between,
+    leases_current,
 )
 from .strategies import (
     storage_indexes,
@@ -469,31 +469,3 @@ class MaintainLeasesFromRootTests(TestCase):
                 min_lease_remaining,
             ))
         )
-
-
-def leases_current(relevant_storage_indexes, now, min_lease_remaining):
-    """
-    Return a matcher on a ``DummyStorageServer`` instance which matches
-    servers for which the leases on the given storage indexes do not expire
-    before ``min_lease_remaining``.
-    """
-    return AfterPreprocessing(
-        # Get share stats for storage indexes we should have
-        # visited and maintained.
-        lambda storage_server: list(
-            stat
-            for (storage_index, stat)
-            in storage_server.buckets.items()
-            if storage_index in relevant_storage_indexes
-        ),
-        AllMatch(
-            AfterPreprocessing(
-                # Lease expiration for anything visited must be
-                # further in the future than min_lease_remaining,
-                # either because it had time left or because we
-                # renewed it.
-                lambda share_stat: datetime.utcfromtimestamp(share_stat.lease_expiration),
-                GreaterThan(now + min_lease_remaining),
-            ),
-        ),
-    )
-- 
GitLab