Skip to content

Commit 88ee43b

Browse files
authored
ARROW-98 Test Against Capped Collections (#87)
1 parent 01dceed commit 88ee43b

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

bindings/python/test/test_pymongoarrow.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,35 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from unittest import TestCase
14+
import unittest
15+
from test import client_context
1516

17+
from pymongoarrow.api import find_arrow_all
18+
from pymongoarrow.schema import Schema
1619
from pymongoarrow.version import __version__
1720

1821

19-
class TestPyMongoArrow(TestCase):
22+
class TestPyMongoArrow(unittest.TestCase):
23+
@classmethod
24+
def setUpClass(cls):
25+
if not client_context.connected:
26+
raise unittest.SkipTest("cannot connect to MongoDB")
27+
cls.client = client_context.get_client()
28+
2029
def test_version(self):
2130
self.assertIsNotNone(__version__)
2231
self.assertIsInstance(__version__, str)
32+
33+
def test_capped_collection(self):
34+
self.client.test.drop_collection("test")
35+
self.client.test.create_collection("test", capped=True, size=5000)
36+
schema = Schema({"data": bool})
37+
data = [{"data": False} for _ in range(1000)]
38+
self.client.test.test.insert_many(data)
39+
40+
# Data should have been capped.
41+
cursor = self.client.test.test.find({})
42+
total = len(list(cursor))
43+
self.assertLess(total, 1000)
44+
table = find_arrow_all(self.client.test.test, {}, schema=schema)
45+
self.assertEqual(table.shape, (total, 1))

0 commit comments

Comments
 (0)