@@ -26,15 +26,17 @@ def absjoin(*paths):
26
26
test_file_dir = absjoin (thisdir , '../../tests/test_files' )
27
27
basic_docx_path = absjoin (test_file_dir , 'test.docx' )
28
28
basic_pptx_path = absjoin (test_file_dir , 'test.pptx' )
29
+ basic_xlsx_path = absjoin (test_file_dir , 'test.xlsx' )
29
30
saved_docx_path = absjoin (scratch_dir , 'test_out.docx' )
30
31
saved_pptx_path = absjoin (scratch_dir , 'test_out.pptx' )
32
+ saved_xlsx_path = absjoin (scratch_dir , 'test_out.xlsx' )
31
33
32
34
33
35
# given ====================================================
34
36
35
37
@given ('a clean working directory' )
36
38
def step_given_clean_working_dir (context ):
37
- files_to_clean_out = (saved_docx_path , saved_pptx_path )
39
+ files_to_clean_out = (saved_docx_path , saved_pptx_path , saved_xlsx_path )
38
40
for path in files_to_clean_out :
39
41
if os .path .isfile (path ):
40
42
os .remove (path )
@@ -47,6 +49,11 @@ def step_given_python_opc_working_environment(context):
47
49
48
50
# when =====================================================
49
51
52
+ @when ('I open an Excel file' )
53
+ def step_when_open_basic_xlsx (context ):
54
+ context .pkg = OpcPackage .open (basic_xlsx_path )
55
+
56
+
50
57
@when ('I open a PowerPoint file' )
51
58
def step_when_open_basic_pptx (context ):
52
59
context .pkg = OpcPackage .open (basic_pptx_path )
@@ -71,6 +78,13 @@ def step_when_save_presentation_package(context):
71
78
context .pkg .save (saved_pptx_path )
72
79
73
80
81
+ @when ('I save the spreadsheet package' )
82
+ def step_when_save_spreadsheet_package (context ):
83
+ if os .path .isfile (saved_xlsx_path ):
84
+ os .remove (saved_xlsx_path )
85
+ context .pkg .save (saved_xlsx_path )
86
+
87
+
74
88
# then =====================================================
75
89
76
90
@then ('the expected package rels are loaded' )
@@ -224,3 +238,12 @@ def step_then_see_pptx_file_in_working_dir(context):
224
238
minimum = 20000
225
239
filesize = os .path .getsize (saved_pptx_path )
226
240
assert filesize > minimum
241
+
242
+
243
+ @then ('I see the xlsx file in the working directory' )
244
+ def step_then_see_xlsx_file_in_working_dir (context ):
245
+ reason = "file '%s' not found" % saved_xlsx_path
246
+ assert os .path .isfile (saved_xlsx_path ), reason
247
+ minimum = 30000
248
+ filesize = os .path .getsize (saved_xlsx_path )
249
+ assert filesize > minimum
0 commit comments