Browse Source

rmd_reader: Unit tests updated

Jari Karppinen 9 years ago
parent
commit
c1ea82d5b7
1 changed files with 30 additions and 3 deletions
  1. 30 3
      rmd_reader/test_rmd_reader.py

+ 30 - 3
rmd_reader/test_rmd_reader.py

@@ -75,7 +75,7 @@ plot(cars)
             'OUTPUT_PATH': self.outputdir,
             'RMD_READER_KNITR_OPTS_CHUNK': {'fig.path' : '%s/' % self.figpath},
             'RMD_READER_KNITR_OPTS_KNIT': {'progress' : True, 'verbose': True},
-            'RMD_READER_RENAME_PLOT': False,
+            'RMD_READER_RENAME_PLOT': 'disable',
             'PLUGIN_PATHS': ['../'],
             'PLUGINS': ['rmd_reader'],
         })
@@ -104,7 +104,7 @@ plot(cars)
             'OUTPUT_PATH': self.outputdir,
             'RMD_READER_KNITR_OPTS_CHUNK': {'fig.path' : '%s/' % self.figpath},
             'RMD_READER_KNITR_OPTS_KNIT': {'progress' : True, 'verbose': True},
-            'RMD_READER_RENAME_PLOT': True,
+            'RMD_READER_RENAME_PLOT': 'chunklabel',
             'PLUGIN_PATHS': ['../'],
             'PLUGINS': ['rmd_reader'],
         })
@@ -125,8 +125,35 @@ plot(cars)
         logging.debug(images)
         self.assertTrue(len(images) == 1,'Contents of images dir is not correct: %s' % ','.join(images))
 
+    def testKnitrSettings3(self):
+        settings = read_settings(path=None, override={
+            'LOAD_CONTENT_CACHE': False,
+            'PATH': self.contentdir,
+            'OUTPUT_PATH': self.outputdir,
+            'RMD_READER_KNITR_OPTS_CHUNK': {'fig.path' : '%s/' % self.figpath},
+            'RMD_READER_KNITR_OPTS_KNIT': {'progress' : True, 'verbose': True},
+            'RMD_READER_RENAME_PLOT': 'directory',
+            'PLUGIN_PATHS': ['../'],
+            'PLUGINS': ['rmd_reader'],
+        })
+        pelican = Pelican(settings=settings)
+        pelican.run()
+
+        outputfilename = os.path.join(self.outputdir,'%s.html' % self.testtitle)
+        self.assertTrue(os.path.exists(outputfilename),'File %s was not created.' % outputfilename)
+
+        imagesdir = os.path.join(self.outputdir, self.figpath)
+        self.assertTrue(os.path.exists(imagesdir), 'figpath not created.')
+
+        imagefile = os.path.join(imagesdir, os.path.splitext(os.path.split(self.contentfile)[1])[0]) + '-unnamed-chunk-1-1.png'
+        logging.debug(imagefile)
+        self.assertTrue(os.path.exists(imagefile), 'image correctly named.')
+
+        images = glob.glob('%s/*' % imagesdir)
+        logging.debug(images)
+        self.assertTrue(len(images) == 1,'Contents of images dir is not correct: %s' % ','.join(images))
 
 
 if __name__ == "__main__":
     #import sys;sys.argv = ['', 'Test.testName']
-    unittest.main()
+    unittest.main()