Exemple #1
0
    def test_should_file_be_built(self):
        """Test should_file_be_built returns the correct boolean value for
        filepath that should be built.
        """
        service_js_filepath = os.path.join('core', 'pages', 'AudioService.js')
        spec_js_filepath = os.path.join('core', 'pages', 'AudioServiceSpec.js')
        protractor_filepath = os.path.join('extensions', 'protractor.js')

        python_controller_filepath = os.path.join('base.py')
        pyc_test_filepath = os.path.join('core', 'controllers', 'base.pyc')
        python_test_filepath = os.path.join('core', 'tests', 'base_test.py')

        self.assertFalse(build.should_file_be_built(spec_js_filepath))
        self.assertFalse(build.should_file_be_built(protractor_filepath))
        self.assertTrue(build.should_file_be_built(service_js_filepath))

        self.assertFalse(build.should_file_be_built(python_test_filepath))
        self.assertFalse(build.should_file_be_built(pyc_test_filepath))
        self.assertTrue(build.should_file_be_built(python_controller_filepath))

        # Swapping out constants to check if the reverse is true.
        # ALL JS files that ends with ...Service.js should not be built.
        with self.swap(build, 'JS_FILENAME_SUFFIXES_TO_IGNORE',
                       ('Service.js', )):
            self.assertFalse(build.should_file_be_built(service_js_filepath))
            self.assertTrue(build.should_file_be_built(spec_js_filepath))
Exemple #2
0
 def test_get_file_count(self):
     """Test get_file_count returns the correct number of files, excluding
     file with extensions in FILE_EXTENSIONS_TO_IGNORE and files that should
     not be built.
     """
     all_inclusive_file_count = 0
     for _, _, files in os.walk(MOCK_EXTENSIONS_DEV_DIR):
         all_inclusive_file_count += len(files)
     ignored_file_count = 0
     for _, _, files in os.walk(MOCK_EXTENSIONS_DEV_DIR):
         for filename in files:
             if not build.should_file_be_built(filename) or any(
                     filename.endswith(p)
                     for p in build.FILE_EXTENSIONS_TO_IGNORE):
                 ignored_file_count += 1
     self.assertEqual(all_inclusive_file_count - ignored_file_count,
                      build.get_file_count(MOCK_EXTENSIONS_DEV_DIR))