Exemplo n.º 1
0
    def test_exclude_from_page(self):

        # Add in a rule to exclude files in other_* dir
        yaml_data = copy.deepcopy(self.YAML_DATA)
        yaml_data['exclude_from_page'] = 'other_[^/]*/.*'

        # Create an in-memory YAML file from the data
        yaml_file = self._yaml_buffer(yaml_data)

        # Create the suite description using the YAML file
        desc = SuiteDescription(yaml_file, self.temp_dir)

        # Check that the root directory is stored
        self.assertEqual(desc.root_dir(), self.temp_dir)

        # Check that we find the files we expect
        expected_lib = self.LIB_FILES[:]
        expected_lib.remove('other_lib/test.js')

        expected_src = self.SRC_FILES[:]
        expected_src.remove('other_src/test.js')

        expected_spec = self.SPEC_FILES[:]
        expected_spec.remove('other_spec/test.js')

        self.assertEqual(desc.lib_paths(only_in_page=True), expected_lib)
        self.assertEqual(desc.src_paths(only_in_page=True), expected_src)
        self.assertEqual(desc.spec_paths(only_in_page=True), expected_spec)
Exemplo n.º 2
0
    def test_prepend_path(self):

        # Add a path to prepend to source paths in reports
        yaml_data = copy.deepcopy(self.YAML_DATA)
        yaml_data['prepend_path'] = 'base/path'

        # Create an in-memory YAML file from the data
        yaml_file = self._yaml_buffer(yaml_data)

        # Create the suite description using the YAML file
        desc = SuiteDescription(yaml_file, self.temp_dir)

        # Check that the prepend path is stored
        self.assertEqual(desc.prepend_path(), 'base/path')
Exemplo n.º 3
0
    def test_no_fixtures_specified(self):

        # 'fixture_paths' is an optional key
        yaml_data = copy.deepcopy(self.YAML_DATA)
        del yaml_data['fixture_paths']

        # Create an in-memory YAML file from the data
        yaml_file = self._yaml_buffer(yaml_data)

        # Create the suite description using the YAML file
        desc = SuiteDescription(yaml_file, self.temp_dir)

        # Check that we get an empty list of lib paths
        self.assertEqual(desc.fixture_paths(), [])
Exemplo n.º 4
0
    def test_non_js_paths(self):

        # Add extra non-JS files
        yaml_data = copy.deepcopy(self.YAML_DATA)
        yaml_data['src_paths'].append('src.txt')
        yaml_data['spec_paths'].append('src.txt')
        yaml_data['lib_paths'].append('src.txt')

        # Create an in-memory YAML file from the data
        yaml_file = self._yaml_buffer(yaml_data)

        # Create the suite description using the YAML file
        desc = SuiteDescription(yaml_file, self.temp_dir)

        # Check that we ignore those files
        self.assertEqual(desc.lib_paths(), self.LIB_FILES)
        self.assertEqual(desc.src_paths(), self.SRC_FILES)
        self.assertEqual(desc.spec_paths(), self.SPEC_FILES)
Exemplo n.º 5
0
    def test_repeated_paths(self):

        # Repeat paths that are already included in the directories
        yaml_data = copy.deepcopy(self.YAML_DATA)
        yaml_data['src_paths'].append(self.SRC_FILES[0])
        yaml_data['spec_paths'].append(self.SPEC_FILES[0])
        yaml_data['lib_paths'].append(self.LIB_FILES[0])
        yaml_data['fixture_paths'].append(self.FIXTURE_FILES[0])

        # Create an in-memory YAML file from the data
        yaml_file = self._yaml_buffer(yaml_data)

        # Create the suite description using the YAML file
        desc = SuiteDescription(yaml_file, self.temp_dir)

        # Check that we ignore repeats
        self.assertEqual(desc.lib_paths(), self.LIB_FILES)
        self.assertEqual(desc.src_paths(), self.SRC_FILES)
        self.assertEqual(desc.spec_paths(), self.SPEC_FILES)
        self.assertEqual(desc.fixture_paths(), self.FIXTURE_FILES)
Exemplo n.º 6
0
    def test_non_list_data(self):

        # Replace all list values with single values
        yaml_data = copy.deepcopy(self.YAML_DATA)
        yaml_data['lib_paths'] = 'lib'
        yaml_data['src_paths'] = 'src'
        yaml_data['spec_paths'] = 'spec'
        yaml_data['fixture_paths'] = 'fixtures'

        # Create an in-memory YAML file from the data
        yaml_file = self._yaml_buffer(yaml_data)

        # Create the suite description using the YAML file
        desc = SuiteDescription(yaml_file, self.temp_dir)

        # Check that we get the right paths
        # (exclude files from the directories we left out)
        self.assertEqual(desc.lib_paths(), self.LIB_FILES[0:3])
        self.assertEqual(desc.src_paths(), self.SRC_FILES[0:3])
        self.assertEqual(desc.spec_paths(), self.SPEC_FILES[0:3])
Exemplo n.º 7
0
    def test_valid_description(self):

        # Create an in-memory YAML file from the data
        yaml_file = self._yaml_buffer(self.YAML_DATA)

        # Create the suite description using the YAML file
        desc = SuiteDescription(yaml_file, self.temp_dir)

        # Check that the root directory is stored
        self.assertEqual(desc.root_dir(), self.temp_dir)

        # Check that we find the files we expect
        self.assertEqual(desc.suite_name(), self.YAML_DATA['test_suite_name'])
        self.assertEqual(desc.lib_paths(), self.LIB_FILES)
        self.assertEqual(desc.src_paths(), self.SRC_FILES)
        self.assertEqual(desc.spec_paths(), self.SPEC_FILES)
        self.assertEqual(desc.fixture_paths(), self.FIXTURE_FILES)
        self.assertEqual(desc.test_runner(), self.YAML_DATA['test_runner'])
        self.assertEqual(desc.prepend_path(), '')
Exemplo n.º 8
0
    def test_include_and_exclude_from_page(self):

        # Add in a rule to exclude files in other_* dir
        yaml_data = copy.deepcopy(self.YAML_DATA)
        yaml_data['exclude_from_page'] = 'other_[^/]*/.*'

        # Add an override rule to always include other_*/test.js
        yaml_data['include_in_page'] = 'other_[^/]*/test.js'

        # Create an in-memory YAML file from the data
        yaml_file = self._yaml_buffer(yaml_data)

        # Create the suite description using the YAML file
        desc = SuiteDescription(yaml_file, self.temp_dir)

        # Check that the root directory is stored
        self.assertEqual(desc.root_dir(), self.temp_dir)

        # Check that we still get all the files back
        # (the include rule overrides the exclude rule)
        self.assertEqual(desc.lib_paths(only_in_page=True), self.LIB_FILES)
        self.assertEqual(desc.src_paths(only_in_page=True), self.SRC_FILES)
        self.assertEqual(desc.spec_paths(only_in_page=True), self.SPEC_FILES)
Exemplo n.º 9
0
    def test_different_working_dir(self):
        
        # Change the working directory temporarily
        # (the superclass will reset it afterwards)
        os.chdir(self.TEMP_DIRS[0])

        # Create an in-memory YAML file from the data
        yaml_file = self._yaml_buffer(self.YAML_DATA)

        # Create the suite description using the YAML file
        desc = SuiteDescription(yaml_file, self.temp_dir)

        # Check that we find the files we expect
        self.assertEqual(desc.lib_paths(), self.LIB_FILES)
        self.assertEqual(desc.src_paths(), self.SRC_FILES)
        self.assertEqual(desc.spec_paths(), self.SPEC_FILES)
        self.assertEqual(desc.fixture_paths(), self.FIXTURE_FILES)
        self.assertEqual(desc.test_runner(), self.YAML_DATA['test_runner'])