-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_yaml.py
27 lines (21 loc) · 1.22 KB
/
test_yaml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pytest
import yaml
from madato import yaml_file_to_md, yaml_str_to_md
def test_yaml_file_to_md(toys_yaml_str, tmp_path):
# Write the YAML data to a temporary file
p = tmp_path / "toys.yaml"
with open(p, 'w') as f:
# write toys_yaml_str
f.write(toys_yaml_str)
# Convert the YAML file to Markdown using the Rust function
md = yaml_file_to_md(str(p))
print(md)
# Check that the Markdown is as expected
assert "| name | type |color|age_range|price|manufacturer|in_stock|weight|dimensions|safety_certified|country_of_origin|" in md
assert "| Doll 🎎 | Doll |null | 3-5 | 30 | Mattel | false | 0.5 |12 x 4 x 2| true | China |" in md
def test_yaml_str_to_md(toys_yaml_str):
# Convert the YAML data to Markdown using the Rust function
md = yaml_str_to_md(toys_yaml_str)
# Check that the Markdown is as expected
assert "| name | type |color|age_range|price|manufacturer|in_stock|weight|dimensions|safety_certified|country_of_origin|" in md
assert "| Doll 🎎 | Doll |null | 3-5 | 30 | Mattel | false | 0.5 |12 x 4 x 2| true | China |" in md