]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Dropped pfefix from a couple of enums
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 14 Mar 2020 11:28:10 +0000 (00:28 +1300)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 14 Mar 2020 11:28:10 +0000 (00:28 +1300)
psycopg3/pq.py
psycopg3/pq_ctypes.py
psycopg3/pq_enums.py
tests/test_pq.py

index 460da89f630ea75c5e0c73cafbe3bc039fd60122..f0a5dc74753ef56094da246ff0facaf379ee829c 100644 (file)
@@ -11,9 +11,9 @@ implementation-dependant but all the implementations share the same interface.
 
 from .pq_enums import (
     ConnStatus,
-    PostgresPollingStatus,
+    PollingStatus,
     TransactionStatus,
-    PGPing,
+    Ping,
 )
 
 from . import pq_ctypes as pq_module
@@ -23,9 +23,9 @@ PQerror = pq_module.PQerror
 
 __all__ = (
     "ConnStatus",
-    "PostgresPollingStatus",
+    "PollingStatus",
     "TransactionStatus",
-    "PGPing",
+    "Ping",
     "PGconn",
     "PQerror",
 )
index 2675b519671fd2b52cde132613a8fdf2b95c41e3..75a3b69676b73e30051117ad1e0116ea3a2af689 100644 (file)
@@ -13,9 +13,9 @@ from ctypes import c_char_p, pointer
 
 from .pq_enums import (
     ConnStatus,
-    PostgresPollingStatus,
+    PollingStatus,
     TransactionStatus,
-    PGPing,
+    Ping,
 )
 from . import _pq_ctypes as impl
 
@@ -55,7 +55,7 @@ class PGconn:
 
     def connect_poll(self):
         rv = impl.PQconnectPoll(self.pgconn_ptr)
-        return PostgresPollingStatus(rv)
+        return PollingStatus(rv)
 
     def finish(self):
         self.pgconn_ptr, p = None, self.pgconn_ptr
@@ -114,7 +114,7 @@ class PGconn:
 
     def reset_poll(self):
         rv = impl.PQresetPoll(self.pgconn_ptr)
-        return PostgresPollingStatus(rv)
+        return PollingStatus(rv)
 
     @classmethod
     def ping(self, conninfo):
@@ -124,7 +124,7 @@ class PGconn:
             raise TypeError("bytes expected, got %r instead" % conninfo)
 
         rv = impl.PQping(conninfo)
-        return PGPing(rv)
+        return Ping(rv)
 
     @property
     def db(self):
index 5c095834617d6e4c14ad27cb87d5e21ddea77621..cafac184b189b81700fce787626d07724bc9b597 100644 (file)
@@ -24,7 +24,7 @@ class ConnStatus(IntEnum):
     CONNECTION_CHECK_TARGET = auto()
 
 
-class PostgresPollingStatus(IntEnum):
+class PollingStatus(IntEnum):
     PGRES_POLLING_FAILED = 0
     PGRES_POLLING_READING = auto()
     PGRES_POLLING_WRITING = auto()
@@ -40,7 +40,7 @@ class TransactionStatus(IntEnum):
     PQTRANS_UNKNOWN = auto()
 
 
-class PGPing(IntEnum):
+class Ping(IntEnum):
     PQPING_OK = 0
     PQPING_REJECT = auto()
     PQPING_NO_RESPONSE = auto()
index 1773569908985ef4a67f5ccee01e6f8c4a356b58..c6a03ed7206932844146623e34cc07965f00e385 100644 (file)
@@ -3,7 +3,7 @@ from select import select
 
 import pytest
 
-from psycopg3.pq_enums import ConnStatus, PostgresPollingStatus, PGPing
+from psycopg3.pq_enums import ConnStatus, PollingStatus, Ping
 
 
 def test_connectdb(pq, dsn):
@@ -32,11 +32,11 @@ def test_connect_async(pq, dsn):
     while 1:
         assert conn.status != ConnStatus.CONNECTION_BAD
         rv = conn.connect_poll()
-        if rv == PostgresPollingStatus.PGRES_POLLING_OK:
+        if rv == PollingStatus.PGRES_POLLING_OK:
             break
-        elif rv == PostgresPollingStatus.PGRES_POLLING_READING:
+        elif rv == PollingStatus.PGRES_POLLING_READING:
             select([conn.socket], [], [])
-        elif rv == PostgresPollingStatus.PGRES_POLLING_WRITING:
+        elif rv == PollingStatus.PGRES_POLLING_WRITING:
             select([], [conn.socket], [])
         else:
             assert False, rv
@@ -49,11 +49,11 @@ def test_connect_async_bad(pq, dsn):
     while 1:
         assert conn.status != ConnStatus.CONNECTION_BAD
         rv = conn.connect_poll()
-        if rv == PostgresPollingStatus.PGRES_POLLING_FAILED:
+        if rv == PollingStatus.PGRES_POLLING_FAILED:
             break
-        elif rv == PostgresPollingStatus.PGRES_POLLING_READING:
+        elif rv == PollingStatus.PGRES_POLLING_READING:
             select([conn.socket], [], [])
-        elif rv == PostgresPollingStatus.PGRES_POLLING_WRITING:
+        elif rv == PollingStatus.PGRES_POLLING_WRITING:
             select([], [conn.socket], [])
         else:
             assert False, rv
@@ -127,23 +127,23 @@ def test_reset_async(pgconn):
     pgconn.reset_start()
     while 1:
         rv = pgconn.connect_poll()
-        if rv == PostgresPollingStatus.PGRES_POLLING_READING:
+        if rv == PollingStatus.PGRES_POLLING_READING:
             select([pgconn.socket], [], [])
-        elif rv == PostgresPollingStatus.PGRES_POLLING_WRITING:
+        elif rv == PollingStatus.PGRES_POLLING_WRITING:
             select([], [pgconn.socket], [])
         else:
             break
 
-    assert rv == PostgresPollingStatus.PGRES_POLLING_OK
+    assert rv == PollingStatus.PGRES_POLLING_OK
     assert pgconn.status == ConnStatus.CONNECTION_OK
 
 
 def test_ping(pq, dsn):
     rv = pq.PGconn.ping(dsn)
-    assert rv == PGPing.PQPING_OK
+    assert rv == Ping.PQPING_OK
 
     rv = pq.PGconn.ping("port=99999")
-    assert rv == PGPing.PQPING_NO_RESPONSE
+    assert rv == Ping.PQPING_NO_RESPONSE
 
 
 def test_db(pgconn):