model2tex1.gms : Test that model2tex produces a tex file

Description

Contributer: Clemens Westphal


Small Model of Type : GAMS


Category : GAMS Test library


Main file : model2tex1.gms

$title Test that model2tex produces a tex file (MODEL2TEX1,SEQ=678)
* Contributer: Clemens Westphal


* This test requires GMSPython which is only available on the major platforms (Windows, Linux, Mac)
$if not setEnv GMSPYTHONLIB $abort.noError Embedded code Python not ready to be used

$ifThenI %system.buildcode% == WEI $set m2t model2tex.cmd
$else                              $set m2t model2tex.sh
$endIf


$call gamslib -q trnsport
$if errorlevel 1 $abort could not retrieve trnsport
$call rm -f transport.tex alloc1.tex alloc1_landscape.tex

$call gams trnsport lo=%gams.lo% docFile=transport
$if errorlevel 1 $abort could not compile trnsport

$call %m2t% transport > %system.nullfile%
$if errorlevel 1 $abort could not run model2tex
$if not exist transport.tex $abort no TeX file produced


$call gamslib -q aircraft
$if errorlevel 1 $abort could not retrieve aircraft
$call rm -f aircraft.tex alloc1.tex

$call gams aircraft lo=%gams.lo% docFile=aircraft
$if errorlevel 1 $abort could not compile aircraft

$call %m2t% -m=alloc1 -o=alloc1.tex aircraft > %system.nullfile%
$if errorlevel 1 $abort could not run model2tex
$if not exist alloc1.tex $abort no TeX file produced

$onEmbeddedCode Python:
  import json
  jsonFile = 'aircraft.json'
  with open(jsonFile, 'r') as f:
    s = f.read()
  info = json.loads(s)
  info['landscape'] = True
  s = json.dumps(info, indent = 4)
  with open(jsonFile, 'w') as f:
    f.write(s)
$offEmbeddedCode

$  call %m2t% -m=alloc1 -o=alloc1_landscape.tex aircraft > %system.nullfile%
$  if errorlevel 1 $abort could not run model2tex
$  if not exist alloc1_landscape.tex $abort no TeX file produced

$onEmbeddedCode Python:
  with open('alloc1_landscape.tex', 'r') as f:
    s = f.read()
    if not r'\usepackage[landscape]' in s:
      raise Exception("package 'landscape' not found in 'alloc1_landscape.tex'")
$offEmbeddedCode