def testExecuteWithAPIObject(self):
   writeObjectToFile(self.table)
   runner = ProgramRunner(TEST_PROGRAM, 
                          self.table,
                          user_directory=TEST_DIR,
                          program_filename=TEST_PROGRAM_FILE)
   column = self.table.columnFromName("VALID_FORMULA")
   column.setFormula(TEST_PROGRAM)
   error = runner.execute(create_API_object=True)
   self._evaluateRunnerExecution(error)
 def setUp(self):
   self.table = createTable(TABLE_NAME)
   self._addColumn(COLUMN1, cells=COLUMN1_CELLS)
   self.column_a = self._addColumn(COLUMN2, cells=COLUMN2_CELLS)
   self.column_b = self._addColumn(COLUMN5, cells=COLUMN5_CELLS)
   self.column_c = self._addColumn(COLUMNC, cells=COLUMNC_CELLS)
   self.column_valid_formula = self._addColumn(COLUMN_VALID_FORMULA,
                                               formula=VALID_FORMULA)
   writeObjectToFile(self.table)
   self.generator = pg.ProgramGenerator(self.table, TEST_DIR)
Пример #3
0
 def setUp(self):
     self.table = createTable(TABLE_NAME)
     self._addColumn(COLUMN1, cells=COLUMN1_CELLS)
     self.column_a = self._addColumn(COLUMN2, cells=COLUMN2_CELLS)
     self.column_b = self._addColumn(COLUMN5, cells=COLUMN5_CELLS)
     self.column_c = self._addColumn(COLUMNC, cells=COLUMNC_CELLS)
     self.column_valid_formula = self._addColumn(COLUMN_VALID_FORMULA,
                                                 formula=VALID_FORMULA)
     writeObjectToFile(self.table)
     self.generator = pg.ProgramGenerator(self.table, TEST_DIR)
 def testMakePrologueWithoutFormulas(self):
   # Table without formulas
   self.table = createTable(TABLE_NAME)
   self._addColumn(COLUMN1, cells=COLUMN1_CELLS)
   self.column_a = self._addColumn(COLUMN2, cells=COLUMN2_CELLS)
   self.column_b = self._addColumn(COLUMN5, cells=COLUMN5_CELLS)
   self.column_c = self._addColumn(COLUMNC, cells=COLUMNC_CELLS)
   writeObjectToFile(self.table)
   self.generator = pg.ProgramGenerator(self.table, TEST_DIR)
   # Test Prologue and Epilogue
   statements = self.generator._makePrologue()
   self.assertTrue('import' in statements)
   self.assertIsNone(_compile(statements))
   statements = self.generator._makeEpilogue()
   self.assertTrue('s.controller.startBlock' in statements)
   self.assertIsNone(_compile(statements))
Пример #5
0
 def testMakePrologueWithoutFormulas(self):
     # Table without formulas
     self.table = createTable(TABLE_NAME)
     self._addColumn(COLUMN1, cells=COLUMN1_CELLS)
     self.column_a = self._addColumn(COLUMN2, cells=COLUMN2_CELLS)
     self.column_b = self._addColumn(COLUMN5, cells=COLUMN5_CELLS)
     self.column_c = self._addColumn(COLUMNC, cells=COLUMNC_CELLS)
     writeObjectToFile(self.table)
     self.generator = pg.ProgramGenerator(self.table, TEST_DIR)
     # Test Prologue and Epilogue
     statements = self.generator._makePrologue()
     self.assertTrue('import' in statements)
     self.assertIsNone(_compile(statements))
     statements = self.generator._makeEpilogue()
     self.assertTrue('s.controller.startBlock' in statements)
     self.assertIsNone(_compile(statements))
Пример #6
0
 def testWriteObjectToFileAndReadObjectFromFile(self):
     path = os.path.join(TEST_DIR, TESTFILE)
     self.table.setFilepath(path)
     api_util.writeObjectToFile(self.table)
     new_table = api_util.readObjectFromFile(path)
     self.assertTrue(self.table.isEquivalent(new_table))
     #
     self.table.setFilepath(path)
     api_util.writeObjectToFile(self.table)
     new_table = api_util.readObjectFromFile(path)
     self.assertTrue(self.table.isEquivalent(new_table))
     #
     a_dict = {"a": range(5), "b": range(10)}
     api_util.writeObjectToFile(a_dict, filepath=path)
     new_a_dict = api_util.readObjectFromFile(path)
     self.assertEqual(a_dict, new_a_dict)