-
Notifications
You must be signed in to change notification settings - Fork 10
Add MongoDB Extended JSON 2.0 support #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MongoDB Extended JSON 2.0 support #33
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking much better!
test/test_bsonjs.py
Outdated
@@ -291,6 +291,25 @@ def test_load_throws_no_read_attribute(self): | |||
not_file = {} | |||
self.assertRaises(AttributeError, bsonjs.load, not_file) | |||
|
|||
def test_extended(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can rename this to test_mode
now. Can you also add a test case for dump (not dumps) and also add a test for passing the mode as a non-keyword (ie positional) argument?:
bsonjs.dumps(bson_bytes, bsonjs.CANONICAL)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you add the test for dump()?
src/bsonjs.c
Outdated
} | ||
else if(mode == 0){ | ||
json = bson_as_json(b, json_len); | ||
}else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting of this if/else if/else block is still inconsistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not resolved. Following the existing if/else statements in this file it should be:
if (mode == 1) {
json = bson_as_relaxed_extended_json(b, json_len);
} else if (mode == 2) {
json = bson_as_canonical_extended_json(b, json_len);
} else if (mode == 0) {
json = bson_as_json(b, json_len);
} else {
...
}
… positional argument
src/bsonjs.c
Outdated
} | ||
else if(mode == 0){ | ||
json = bson_as_json(b, json_len); | ||
}else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not resolved. Following the existing if/else statements in this file it should be:
if (mode == 1) {
json = bson_as_relaxed_extended_json(b, json_len);
} else if (mode == 2) {
json = bson_as_canonical_extended_json(b, json_len);
} else if (mode == 0) {
json = bson_as_json(b, json_len);
} else {
...
}
src/bsonjs.c
Outdated
}else if(mode == 0){ | ||
json = bson_as_json(b, json_len); | ||
}else{ | ||
PyErr_SetString(PyExc_ValueError, "The value of extended must be one " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extended -> mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the dump() test requested here: #33 (comment)
No description provided.