Skip to content

Commit dbfcbc2

Browse files
committed
address failing tests
1 parent 5c9796a commit dbfcbc2

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

bindings/python/test/test_bson.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class TestBsonToArrowConversionBase(TestCase):
2525
def setUp(self):
2626
self.schema = Schema({"_id": ObjectId, "data": int64(), "title": string()})
27-
self.context = PyMongoArrowContext.from_schema(self.schema)
27+
self.context = PyMongoArrowContext(self.schema)
2828

2929
@staticmethod
3030
def _generate_payload(doclist):
@@ -36,7 +36,7 @@ def _generate_payload(doclist):
3636
def _run_test(self, doclist, as_dict):
3737
payload = type(self)._generate_payload(doclist)
3838

39-
process_bson_stream(payload, self.context)
39+
self.context.process_bson_stream(payload)
4040
table = self.context.finish()
4141
table_dict = table.to_pydict()
4242

@@ -104,13 +104,13 @@ def test_simple(self):
104104
schema = Schema({"_id": ObjectId, "data": int64(), "fake": pa.float16()})
105105
msg = 'Unsupported data type in schema for field "fake" of type "halffloat"'
106106
with self.assertRaisesRegex(ValueError, msg):
107-
PyMongoArrowContext.from_schema(schema)
107+
PyMongoArrowContext(schema)
108108

109109

110110
class TestNonAsciiFieldName(TestBsonToArrowConversionBase):
111111
def setUp(self):
112112
self.schema = Schema({"_id": ObjectIdType(), "dätá": int64()})
113-
self.context = PyMongoArrowContext.from_schema(self.schema)
113+
self.context = PyMongoArrowContext(self.schema)
114114

115115
def test_simple(self):
116116
ids = [ObjectId() for i in range(4)]
@@ -150,7 +150,7 @@ def test_object_id_type(self):
150150
class TestInt64Type(TestBsonToArrowConversionBase):
151151
def setUp(self):
152152
self.schema = Schema({"data": Int64})
153-
self.context = PyMongoArrowContext.from_schema(self.schema)
153+
self.context = PyMongoArrowContext(self.schema)
154154

155155
def test_simple(self):
156156
docs = [
@@ -165,7 +165,7 @@ def test_simple(self):
165165
class TestBooleanType(TestBsonToArrowConversionBase):
166166
def setUp(self):
167167
self.schema = Schema({"data": bool})
168-
self.context = PyMongoArrowContext.from_schema(self.schema)
168+
self.context = PyMongoArrowContext(self.schema)
169169

170170
def test_simple(self):
171171
docs = [
@@ -183,7 +183,7 @@ def test_simple(self):
183183
class TestStringType(TestBsonToArrowConversionBase):
184184
def setUp(self):
185185
self.schema = Schema({"data": str})
186-
self.context = PyMongoArrowContext.from_schema(self.schema)
186+
self.context = PyMongoArrowContext(self.schema)
187187

188188
def test_simple(self):
189189
docs = [
@@ -197,7 +197,7 @@ def test_simple(self):
197197
class TestDecimal128Type(TestBsonToArrowConversionBase):
198198
def setUp(self):
199199
self.schema = Schema({"data": Decimal128})
200-
self.context = PyMongoArrowContext.from_schema(self.schema)
200+
self.context = PyMongoArrowContext(self.schema)
201201

202202
def test_simple(self):
203203
docs = [
@@ -212,7 +212,7 @@ def test_simple(self):
212212
class TestSubdocumentType(TestBsonToArrowConversionBase):
213213
def setUp(self):
214214
self.schema = Schema({"data": dict(x=bool)})
215-
self.context = PyMongoArrowContext.from_schema(self.schema)
215+
self.context = PyMongoArrowContext(self.schema)
216216

217217
def test_simple(self):
218218
docs = [
@@ -237,7 +237,7 @@ def test_simple(self):
237237

238238
def test_nested(self):
239239
self.schema = Schema({"data": dict(x=bool, y=dict(a=int))})
240-
self.context = PyMongoArrowContext.from_schema(self.schema)
240+
self.context = PyMongoArrowContext(self.schema)
241241

242242
docs = [
243243
{"data": dict(x=True, y=dict(a=1))},

bindings/python/test/test_builders.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_simple(self):
187187
manager.process_bson_stream(data, len(data))
188188
array_map = manager.finish()
189189
assert list(array_map) == ["a"]
190-
assert next(iter(array_map.values())).to_pylist() == [1, 2, None, 4]
190+
assert next(iter(array_map.values())).finish().to_pylist() == [1, 2, None, 4]
191191

192192
def test_nested_object(self):
193193
inner_values = []
@@ -204,6 +204,8 @@ def test_nested_object(self):
204204
data = b"".join(encode(v) for v in values)
205205
manager.process_bson_stream(data, len(data))
206206
array_map = manager.finish()
207+
for key, value in array_map.items():
208+
array_map[key] = value.finish()
207209
assert sorted(array_map.keys()) == [
208210
"c",
209211
"c.a",
@@ -220,7 +222,7 @@ def test_nested_object(self):
220222
"g[].a",
221223
]
222224
# Dict has its top level keys.
223-
assert array_map["c"] == set(("a", "b", "c", "d", "e", "f"))
225+
assert array_map["c"] == ["a", "b", "c", "d", "e", "f"]
224226
# Deferred nested field.
225227
assert array_map["c.c"].to_pylist() == [None, None, None, None, 1.0]
226228
assert array_map["f"].to_pylist() == [None, None, None, None, None]

bindings/python/test/test_datetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_context_creation_fails_with_unsupported_granularity(self):
5252
for g in unsupported_granularities:
5353
schema = Schema({"_id": int32(), "data": timestamp(g)})
5454
with self.assertRaises(TypeError):
55-
PyMongoArrowContext.from_schema(schema)
55+
PyMongoArrowContext(schema)
5656

5757
def test_round_trip(self):
5858
expected = Table.from_pydict(

0 commit comments

Comments
 (0)