Skip to content

Commit 6e60dbc

Browse files
author
Steve Canny
committed
add save-package.feature
1 parent cdaf4f7 commit 6e60dbc

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

features/environment.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# environment.py
4+
#
5+
# Copyright (C) 2013 Steve Canny scanny@cisco.com
6+
#
7+
# This module is part of python-opc and is released under the MIT License:
8+
# http://www.opensource.org/licenses/mit-license.php
9+
10+
"""
11+
Used by behave to set testing environment before and after running acceptance
12+
tests.
13+
"""
14+
15+
import os
16+
17+
scratch_dir = os.path.abspath(
18+
os.path.join(os.path.split(__file__)[0], '_scratch')
19+
)
20+
21+
22+
def before_all(context):
23+
if not os.path.isdir(scratch_dir):
24+
os.mkdir(scratch_dir)

features/open-package.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Feature: Open an OPC package
33
As an Open XML developer
44
I need to open an arbitrary package
55

6-
@wip
76
Scenario: Open a PowerPoint file
87
Given a python-opc working environment
98
When I open a PowerPoint file

features/save-package.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: Save an OPC package
2+
In order to satisfy myself that python-opc might work
3+
As a pptx developer
4+
I want to see it pass a basic round-trip sanity-check
5+
6+
@wip
7+
Scenario: Round-trip a .pptx file
8+
Given a clean working directory
9+
When I open a PowerPoint file
10+
And I save the presentation package
11+
Then I see the pptx file in the working directory

features/steps/opc_steps.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ def absjoin(*paths):
2222
return os.path.abspath(os.path.join(*paths))
2323

2424
thisdir = os.path.split(__file__)[0]
25+
scratch_dir = absjoin(thisdir, '../_scratch')
2526
test_file_dir = absjoin(thisdir, '../../tests/test_files')
2627
basic_pptx_path = absjoin(test_file_dir, 'test.pptx')
28+
saved_pptx_path = absjoin(scratch_dir, 'test_out.pptx')
2729

2830

2931
# given ====================================================
3032

33+
@given('a clean working directory')
34+
def step_given_clean_working_dir(context):
35+
if os.path.isfile(saved_pptx_path):
36+
os.remove(saved_pptx_path)
37+
38+
3139
@given('a python-opc working environment')
3240
def step_given_python_opc_working_environment(context):
3341
pass
@@ -40,6 +48,13 @@ def step_when_open_basic_pptx(context):
4048
context.pkg = OpcPackage.open(basic_pptx_path)
4149

4250

51+
@when('I save the presentation package')
52+
def step_when_save_presentation_package(context):
53+
if os.path.isfile(saved_pptx_path):
54+
os.remove(saved_pptx_path)
55+
context.pkg.save(saved_pptx_path)
56+
57+
4358
# then =====================================================
4459

4560
@then('the expected package rels are loaded')

0 commit comments

Comments
 (0)