Exemple #1
0
 def setUp(self):
     """Makes a temporary output directory and stores it in self.output_path.
 """
     super(TestCaseWithOutputDir, self).setUp()
     self.output_path = os.path.join(self.temp_path, MINIMAL_APP_NAME)
     caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path,
                                  BOILERPLATE_DIR, REPORT_DIR)
Exemple #2
0
 def test_setup_output_dir_makes_polyfill_dir(self):
     """Tests that setup_output_dir makes a polyfill directory."""
     caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path,
                                  BOILERPLATE_DIR, REPORT_DIR)
     self.assertTrue(
         os.path.isdir(
             os.path.join(self.output_path, BOILERPLATE_DIR, 'polyfills')))
 def setUp(self):
   """Makes a temporary output directory and stores it in self.output_path.
   """
   super(TestCaseWithOutputDir, self).setUp()
   self.output_path = os.path.join(self.temp_path, MINIMAL_APP_NAME)
   caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path,
                                BOILERPLATE_DIR, REPORT_DIR)
 def test_setup_output_dir_force_false(self):
   """Tests that force=False disallows overwriting of an existing directory."""
   os.mkdir(self.output_path)
   with self.assertRaises(caterpillar.CaterpillarError) as e:
     caterpillar.setup_output_dir(
         MINIMAL_PATH, self.output_path, BOILERPLATE_DIR, REPORT_DIR)
   self.assertEqual(e.exception.message, 'Output directory already exists.')
 def test_input_dir_does_not_exist(self):
   """Tests that an error is raised if the input directory does not exist."""
   input_dir = os.path.join(self.temp_path, 'not a directory')
   with self.assertRaises(caterpillar.CaterpillarError) as e:
     caterpillar.setup_output_dir(
         input_dir, self.output_path, BOILERPLATE_DIR, REPORT_DIR)
   self.assertEqual(e.exception.message,
       'Input directory `{}` does not exist.'.format(input_dir))
Exemple #6
0
 def test_setup_output_dir_force_false(self):
     """Tests that force=False disallows overwriting of an existing directory."""
     os.mkdir(self.output_path)
     with self.assertRaises(caterpillar.CaterpillarError) as e:
         caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path,
                                      BOILERPLATE_DIR, REPORT_DIR)
     self.assertEqual(e.exception.message,
                      'Output directory already exists.')
 def test_setup_output_dir_no_unexpected_files(self):
   """Tests that setup_output_dir doesn't add any unexpected files."""
   caterpillar.setup_output_dir(
       MINIMAL_PATH, self.output_path, BOILERPLATE_DIR, REPORT_DIR)
   for root, _, files in os.walk(self.output_path):
     for name in files:
       relpath = os.path.relpath(os.path.join(root, name), self.output_path)
       path = os.path.join(MINIMAL_PATH, relpath)
       self.assertTrue(os.path.exists(path))
 def test_setup_output_dir_copies_all_files(self):
   """Tests that setup_output_dir copies all input files to the output app."""
   caterpillar.setup_output_dir(
       MINIMAL_PATH, self.output_path, BOILERPLATE_DIR, REPORT_DIR)
   for root, _, files in os.walk(MINIMAL_PATH):
     for name in files:
       relpath = os.path.relpath(os.path.join(root, name), MINIMAL_PATH)
       path = os.path.join(self.output_path, relpath)
       self.assertTrue(os.path.exists(path))
Exemple #9
0
 def test_input_dir_does_not_exist(self):
     """Tests that an error is raised if the input directory does not exist."""
     input_dir = os.path.join(self.temp_path, 'not a directory')
     with self.assertRaises(caterpillar.CaterpillarError) as e:
         caterpillar.setup_output_dir(input_dir, self.output_path,
                                      BOILERPLATE_DIR, REPORT_DIR)
     self.assertEqual(
         e.exception.message,
         'Input directory `{}` does not exist.'.format(input_dir))
 def test_setup_output_dir_force_true_copies_all_files(self):
   """Tests that force=True allows overwriting of an existing directory."""
   os.mkdir(self.output_path)
   caterpillar.setup_output_dir(
       MINIMAL_PATH, self.output_path, BOILERPLATE_DIR, REPORT_DIR, force=True)
   for root, _, files in os.walk(MINIMAL_PATH):
     for name in files:
       relpath = os.path.relpath(os.path.join(root, name), MINIMAL_PATH)
       path = os.path.join(self.output_path, relpath)
       self.assertTrue(os.path.exists(path))
Exemple #11
0
 def test_setup_output_dir_copies_all_files(self):
     """Tests that setup_output_dir copies all input files to the output app."""
     caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path,
                                  BOILERPLATE_DIR, REPORT_DIR)
     for root, _, files in os.walk(MINIMAL_PATH):
         for name in files:
             relpath = os.path.relpath(os.path.join(root, name),
                                       MINIMAL_PATH)
             path = os.path.join(self.output_path, relpath)
             self.assertTrue(os.path.exists(path))
Exemple #12
0
 def test_setup_output_dir_no_unexpected_files(self):
     """Tests that setup_output_dir doesn't add any unexpected files."""
     caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path,
                                  BOILERPLATE_DIR, REPORT_DIR)
     for root, _, files in os.walk(self.output_path):
         for name in files:
             relpath = os.path.relpath(os.path.join(root, name),
                                       self.output_path)
             path = os.path.join(MINIMAL_PATH, relpath)
             self.assertTrue(os.path.exists(path))
  def test_input_not_a_directory(self):
    """Tests that an error is raised if the input is not a directory."""
    input_path = os.path.join(self.temp_path, 'a file')
    with open(input_path, 'w') as _:
      pass

    with self.assertRaises(caterpillar.CaterpillarError) as e:
      caterpillar.setup_output_dir(
          input_path, self.output_path, BOILERPLATE_DIR, REPORT_DIR)
    self.assertEqual(e.exception.message,
        'Input `{}` is not a directory.'.format(input_path))
Exemple #14
0
    def test_input_not_a_directory(self):
        """Tests that an error is raised if the input is not a directory."""
        input_path = os.path.join(self.temp_path, 'a file')
        with open(input_path, 'w') as _:
            pass

        with self.assertRaises(caterpillar.CaterpillarError) as e:
            caterpillar.setup_output_dir(input_path, self.output_path,
                                         BOILERPLATE_DIR, REPORT_DIR)
        self.assertEqual(e.exception.message,
                         'Input `{}` is not a directory.'.format(input_path))
  def test_setup_output_dir_force_true_deletes_existing_files(self):
    """Tests that force=True deletes files in existing directory."""
    os.mkdir(self.output_path)
    test_filename = 'existing file'
    with open(os.path.join(self.output_path, test_filename), 'w') as f:
      pass

    caterpillar.setup_output_dir(
        MINIMAL_PATH, self.output_path, BOILERPLATE_DIR, REPORT_DIR, force=True)

    self.assertFalse(
        os.path.exists(os.path.join(self.output_path, test_filename)))
Exemple #16
0
 def test_setup_output_dir_force_true_copies_all_files(self):
     """Tests that force=True allows overwriting of an existing directory."""
     os.mkdir(self.output_path)
     caterpillar.setup_output_dir(MINIMAL_PATH,
                                  self.output_path,
                                  BOILERPLATE_DIR,
                                  REPORT_DIR,
                                  force=True)
     for root, _, files in os.walk(MINIMAL_PATH):
         for name in files:
             relpath = os.path.relpath(os.path.join(root, name),
                                       MINIMAL_PATH)
             path = os.path.join(self.output_path, relpath)
             self.assertTrue(os.path.exists(path))
Exemple #17
0
    def test_setup_output_dir_force_true_deletes_existing_files(self):
        """Tests that force=True deletes files in existing directory."""
        os.mkdir(self.output_path)
        test_filename = 'existing file'
        with open(os.path.join(self.output_path, test_filename), 'w') as f:
            pass

        caterpillar.setup_output_dir(MINIMAL_PATH,
                                     self.output_path,
                                     BOILERPLATE_DIR,
                                     REPORT_DIR,
                                     force=True)

        self.assertFalse(
            os.path.exists(os.path.join(self.output_path, test_filename)))
 def test_setup_output_dir_makes_report_dir(self):
   """Tests that setup_output_dir makes a report directory."""
   caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path,
                                BOILERPLATE_DIR, REPORT_DIR)
   self.assertTrue(
       os.path.isdir(os.path.join(self.output_path, REPORT_DIR)))
Exemple #19
0
 def test_setup_output_dir_makes_dir(self):
     """Tests that setup_output_dir makes the expected output directory."""
     caterpillar.setup_output_dir(MINIMAL_PATH, self.output_path,
                                  BOILERPLATE_DIR, REPORT_DIR)
     self.assertTrue(os.path.isdir(self.output_path))