Ejemplo n.º 1
0
def test_page():
    if not ppt:
        return

    NAME_PPT = 'testppt.pptx'
    path_ppt = os.path.join(TESTDIR, NAME_PPT)
    NAME_PNG = 'abc.png'
    path_png = os.path.join(TESTDIR, NAME_PNG)

    directive = pptshape.directive.PPTShape(None, None, None, 
             None, None, None, None, None, None)

    if os.path.exists(path_png):
        os.unlink(path_png)

    directive.arguments = [NAME_PNG]
    directive.state = mock.Mock()
    directive.state.document.current_source = os.path.join(TESTDIR, 'test.rst')
    directive.options = {
        'pptfilename': NAME_PPT,
        'shapename': '#2.1',
    }
    directive.run()
    assert os.path.exists(path_png)
    
Ejemplo n.º 2
0
def test_update():
    NAME_PNG = 'abc.png'
    path_png = os.path.join(TESTDIR, NAME_PNG)

    NAME_PPT = 'testppt.pptx'
    path_ppt = os.path.join(TESTDIR, NAME_PPT)

    directive = pptshape.directive.PPTShape(None, None, None, 
             None, None, None, None, None, None)
    if os.path.exists(path_png):
        os.unlink(path_png)

    directive.arguments = [NAME_PNG]
    directive.state = mock.Mock()
    directive.state.document.current_source = os.path.join(TESTDIR, 'test.rst')
    directive.options = {
        'pptfilename': NAME_PPT,
        'shapename': 'shape-title',
    }
    directive.run()
    assert os.path.exists(path_png)
    
    os.utime(path_png, (0, 0))
    directive.run()

    assert os.stat(path_png).st_mtime != 0

    # Make png file empty.
    open(path_png, 'w').close()

    directive.run()
    assert os.path.getsize(path_png) == 0
Ejemplo n.º 3
0
def test_update():
    if not ppt:
        return

    NAME_PNG = 'abc.png'
    path_png = os.path.join(TESTDIR, NAME_PNG)

    NAME_PPT = 'testppt.pptx'
    path_ppt = os.path.join(TESTDIR, NAME_PPT)

    directive = pptshape.directive.PPTShape(None, None, None, None, None, None,
                                            None, None, None)
    if os.path.exists(path_png):
        os.unlink(path_png)

    directive.arguments = [NAME_PNG]
    directive.state = mock.Mock()
    directive.state.document.current_source = os.path.join(TESTDIR, 'test.rst')
    directive.options = {
        'pptfilename': NAME_PPT,
        'shapename': 'shape-title',
    }
    directive.run()
    assert os.path.exists(path_png)

    os.utime(path_png, (0, 0))
    directive.run()

    assert os.stat(path_png).st_mtime != 0

    # Make png file empty.
    open(path_png, 'w').close()

    directive.run()
    assert os.path.getsize(path_png) == 0