Esempio n. 1
0
    def test_normal(self):
        bake.Opt = Options(recipe='t.py', xls='t.xls')
        recipe = imp.load_source("recipe", bake.Opt.recipe_file)
        for fn in bake.Opt.xls_files:
            bake.per_file(fn, recipe)
        with open("test/t_out.csv") as f:
            raw = list(UnicodeReader(f))
        self.assertEqual(raw[0][0], 'observation')
        self.assertEqual(raw[-1][0], '*' * 9)
        self.assertEqual(raw[-1][1], '9')
        data = zip(*raw[1:-1])  # transpose
        setdata = [set(x) for x in data]
        print list(enumerate(setdata))
        self.assertEqual(set([u'', '4']), setdata[0])
        assert '(d)' in setdata[1]

        self.assertEqual(set(['Jan 2001', '2010', 'Jan-Mar 2005']),
                         setdata[17])
        self.assertEqual(setdata[18], setdata[17])
        self.assertEqual(set(['Year', 'Quarter', 'Month']), setdata[20])

        self.assertEqual(set(["header_1"]), setdata[35])
        self.assertEqual(set(["ref"]), setdata[35 + 8])
        self.assertEqual(set(["table"]), setdata[35 + 8 + 8])

        self.assertEqual(setdata[38], set(["static_value"]))
        self.assertEqual(setdata[38 + 8],
                         set(u'B2 B3 B4 C2 C3 C4 D2 D3 D4'.split(' ')))
        self.assertEqual(setdata[38 + 8 + 8], set(["Sheet1"]))
Esempio n. 2
0
    def test_normal(self):
        bake.Opt = Options(recipe='t.py', xls='t.xls')
        recipe = imp.load_source("recipe", bake.Opt.recipe_file)
        for fn in bake.Opt.xls_files:
            bake.per_file(fn, recipe)
        with open("test/t_out.csv") as f:
            raw = list(UnicodeReader(f))
        self.assertEqual(raw[0][0], 'observation')
        self.assertEqual(raw[-1][0], '*'*9)
        self.assertEqual(raw[-1][1], '9')
        data = zip(*raw[1:-1])  # transpose
        setdata = [set(x) for x in data]
        print list(enumerate(setdata))
        self.assertEqual(set([u'', '4']), setdata[0])
        assert '(d)' in setdata[1]

        self.assertEqual(set(['Jan 2001', '2010', 'Jan-Mar 2005']), setdata[17])
        self.assertEqual(setdata[18], setdata[17])
        self.assertEqual(set(['Year', 'Quarter', 'Month']), setdata[20])

        self.assertEqual(set(["header_1"]), setdata[35])
        self.assertEqual(set(["ref"]), setdata[35+8])
        self.assertEqual(set(["table"]), setdata[35+8+8])

        self.assertEqual(setdata[38], set(["static_value"]))
        self.assertEqual(setdata[38+8], set(u'B2 B3 B4 C2 C3 C4 D2 D3 D4'.split(' ')))
        self.assertEqual(setdata[38+8+8], set(["Sheet1"]))
Esempio n. 3
0
 def test_parse_ob(self):
     bake.Opt = Options(recipe='obs.py', xls='rich.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     bake.Opt.preview_filename = "t_rich.xls"
     bake.Opt.csv_filename = "t_rich.csv"
     for fn in bake.Opt.xls_files:
         bake.per_file(fn, recipe)
Esempio n. 4
0
 def test_parse_ob(self):
     bake.Opt = Options(recipe='obs.py', xls='rich.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     bake.Opt.preview_filename = "t_rich.xls"
     bake.Opt.csv_filename = "t_rich.csv"
     for fn in bake.Opt.xls_files:
         bake.per_file(fn, recipe)
Esempio n. 5
0
 def test_normal(self):
     bake.Opt = Options(recipe='bail.py', xls='t.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     try:
         for fn in bake.Opt.xls_files:
             bake.per_file(fn, recipe)
     except SystemExit:
         pass
     else:
         raise Exception, "Should have been System Exit"
Esempio n. 6
0
 def test_subdim(self):
     bake.Opt = Options(recipe='subdim_recipe.py', xls='glue.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     for fn in bake.Opt.xls_files:
         bake.per_file(fn, recipe)
     with open("test/t_out.csv") as f:
         for row in UnicodeReader(f):
             if '- Q1 1997' in row:
                 return
     assert False, "No '- Q1 1997' in subdim"
Esempio n. 7
0
 def test_normal(self):
     bake.Opt = Options(recipe='bail.py', xls='t.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     try:
         for fn in bake.Opt.xls_files:
             bake.per_file(fn, recipe)
     except SystemExit:
         pass
     else:
         raise Exception, "Should have been System Exit"
Esempio n. 8
0
 def test_subdim(self):
     bake.Opt = Options(recipe='subdim_recipe.py', xls='glue.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     for fn in bake.Opt.xls_files:
         bake.per_file(fn, recipe)
     with open("test/t_out.csv") as f:
         for row in UnicodeReader(f):
             if '- Q1 1997' in row:
                 return
     assert False, "No '- Q1 1997' in subdim"
Esempio n. 9
0
 def test_header(self):
     with open("test/t_out.csv", "w") as f:
         f.write('blat')
     bake.Opt = Options(recipe="supersub.py", xls="supersub.xls")
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     for fn in bake.Opt.xls_files:
         bake.per_file(fn, recipe)
     with open("test/t_out.csv") as f:
         raw = list(UnicodeReader(f))
         assert "OB" in raw[1]
         assert "HEADER" in raw[1]
Esempio n. 10
0
 def test_header(self):
     with open("test/t_out.csv", "w") as f:
         f.write('blat')
     bake.Opt = Options(recipe="supersub.py", xls="supersub.xls")
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     for fn in bake.Opt.xls_files:
         bake.per_file(fn, recipe)
     with open("test/t_out.csv") as f:
         raw = list(UnicodeReader(f))
         assert "OB" in raw[1]
         assert "HEADER" in raw[1]
Esempio n. 11
0
 def test_failparam(self):
     bake.Opt = Options(recipe='paramfail.py', xls='t.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     try:
         for fn in bake.Opt.xls_files:
             bake.per_file(fn, recipe)
     except Exception as e:
         msg = repr(e)
         assert "NotEnoughParams" in msg
         assert 'PARAM(2)' in msg
         assert "['1999', '2000']" in msg
Esempio n. 12
0
 def test_failparam(self):
     bake.Opt = Options(recipe='paramfail.py', xls='t.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     try:
         for fn in bake.Opt.xls_files:
             bake.per_file(fn, recipe)
     except Exception as e:
         msg = repr(e)
         assert "NotEnoughParams" in msg
         assert 'PARAM(2)' in msg
         assert "['1999', '2000']" in msg
Esempio n. 13
0
 def test_subdim(self):
     bake.Opt = Options(recipe='glue_recipe.py', xls='glue.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     for fn in bake.Opt.xls_files:
         bake.per_file(fn, recipe)
     with open("test/t_out.csv") as f:
         for row in UnicodeReader(f):
             if row[0] == "8828.0":
                 assert "All Work  " in row, row
                 assert "2014.0" in row, row
                 return
     assert False, "No 8828 for 2014 All Work"
Esempio n. 14
0
 def test_subdim(self):
     bake.Opt = Options(recipe='glue_recipe.py', xls='glue.xls')
     recipe = imp.load_source("recipe", bake.Opt.recipe_file)
     for fn in bake.Opt.xls_files:
         bake.per_file(fn, recipe)
     with open("test/t_out.csv") as f:
         for row in UnicodeReader(f):
             if row[0] == "8828.0":
                 assert "All Work  " in row, row
                 assert "2014.0" in row, row
                 return
     assert False, "No 8828 for 2014 All Work"