Skip to content

Commit

Permalink
Add roundtrip test case, use simple HashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Aug 13, 2024
1 parent 11c222c commit 142de81
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true,
"source_hidden": true
},
"vscode": {
"languageId": "javascript"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true,
"source_hidden": true
},
"vscode": {
"languageId": "javascript"
}
Expand Down
8 changes: 8 additions & 0 deletions crates/ruff_notebook/src/notebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,4 +596,12 @@ print("after empty cells")
);
Ok(())
}

#[test]
fn round_trip() {
let path = notebook_path("vscode_language_id.ipynb");
let expected = std::fs::read_to_string(&path).unwrap();
let actual = super::round_trip(&path).unwrap();
assert_eq!(actual, expected);
}
}
4 changes: 2 additions & 2 deletions crates/ruff_notebook/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! a code cell or not without looking at the `cell_type` property, which
//! would require a custom serializer.

use std::collections::BTreeMap;
use std::collections::{BTreeMap, HashMap};

use serde::{Deserialize, Serialize};
use serde_json::Value;
Expand Down Expand Up @@ -171,7 +171,7 @@ pub struct CellMetadata {
pub vscode: Option<CodeCellMetadataVSCode>,
/// Catch-all for metadata that isn't required by Ruff.
#[serde(flatten)]
pub extra: BTreeMap<String, Value>,
pub extra: HashMap<String, Value>,
}

/// VS Code specific cell metadata.
Expand Down

0 comments on commit 142de81

Please sign in to comment.