File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -55,4 +55,8 @@ Check out our example Jupyter Notebook [here](https://nbviewer.jupyter.org/githu
5555
5656# Updating Version
5757
58- See the notes above on downloading and generating the new bsync.py file.
58+ * See the notes above on downloading and generating the new bsync.py file.
59+ * Bump version in ` pyproject.toml ` file
60+ * Add CHANGELOG entry
61+ * Update (or add) generator test in ` .github/ci.yml `
62+ * Update this README with the latest version of testing.
Original file line number Diff line number Diff line change 1+ from lxml import etree
2+ import os
3+ from bsyncpy import bsync
4+
5+
6+ def test_writefile ():
7+ # remove old file
8+ if os .path .exists ("output.xml" ):
9+ os .remove ("output.xml" )
10+ assert os .path .exists ("output.xml" ) == False
11+
12+ # Create a root and set the version attribute
13+ root = bsync .BuildingSync ()
14+ root .set ("version" , "2.4.0" )
15+
16+ # Valid element attributes can also be passed in as kwargs
17+ f = bsync .Facilities (bsync .Facilities .Facility (ID = "Facility-42" ))
18+
19+ # Add the facilities.facility elements to the root
20+ root += f
21+
22+ # write the document to disk
23+ with open ("output.xml" , "wb+" ) as f :
24+ output = etree .tostring (
25+ root .toxml (),
26+ pretty_print = True ,
27+ doctype = '<?xml version="1.0" encoding="UTF-8"?>' ,
28+ )
29+ f .write (output )
30+
31+ # verify that it is written out
32+ assert os .path .exists ("output.xml" ) == True
33+
34+ with open ("output.xml" ) as f :
35+ if '<BuildingSync version="2.4.0">' in f .read ():
36+ assert True
37+ else :
38+ assert False , "Could not find correct BuildingSync version in file"
You can’t perform that action at this time.
0 commit comments