def test_jscs_parse_output_should_return_false_with_xml_output(self): jscs_file = TemporaryFile('w+') jscs_file.write(XML_OUTPUT) jscs_file.seek(0) self.options['jenkins'] = 'True' linter = JSCS(self.options) self.assertTrue(linter.use_jenkins) with OutputCapture(): self.assertFalse(linter.parse_output(jscs_file, 1))
def test_jscs_parse_output_should_return_true_empty_normal_output(self): jscs_file = TemporaryFile('w+') jscs_file.write('') jscs_file.seek(0) self.options['jenkins'] = 'False' linter = JSCS(self.options) self.assertFalse(linter.use_jenkins) with OutputCapture(): self.assertTrue(linter.parse_output(jscs_file, 1))
def test_analysis_should_return_true_when_oserror(self): self.given_a_file_in_test_dir('incorrect.js', INCORRECT_FILE) # The options are fake, so the function should raise an OSError # but return True. self.options['jscs-bin'] = 'FAKE_BIN' with OutputCapture(): self.assertTrue(JSCS(self.options).run())
def test_analysis_should_return_true_when_invalid_file_is_excluded(self): filename = 'incorrect.js' self.given_a_file_in_test_dir(filename, INCORRECT_FILE) self.options['jscs-exclude'] = '{0:s}/{1:s}'.format( self.test_dir, filename) with OutputCapture(): self.assertTrue(JSCS(self.options).run())
def test_analysis_file_should_exist_when_jenkins_is_true(self): parts_dir = mkdtemp() self.given_a_file_in_test_dir('correct.js', CORRECT_FILE) self.options['location'] = parts_dir self.options['jenkins'] = 'True' # need to activate jenkins. with OutputCapture(): JSCS(self.options).run() file_exist = os.path.isfile(os.path.join(parts_dir, 'jscs.xml')) rmtree(parts_dir) self.assertTrue(file_exist)
def test_analysis_should_return_true(self): self.given_a_file_in_test_dir('correct.js', CORRECT_FILE) with OutputCapture(): self.assertTrue(JSCS(self.options).run())
def test_analysis_should_return_false_when_error_found(self): self.given_a_file_in_test_dir('incorrect.js', INCORRECT_FILE) with OutputCapture(): self.assertFalse(JSCS(self.options).run())