def test_delete_tagged_results_no_file(self): path = get_tag_path("test_tag_del", "test_path", self.log_printer) none_path = get_tag_path("None", "test_path", self.log_printer) open(path, "a").close() open(none_path, "a").close() delete_tagged_results("None", "test_path", self.log_printer) self.assertTrue(os.path.exists(none_path)) delete_tagged_results("test_tag_del", "test_path", self.log_printer) self.assertFalse(os.path.exists(path)) delete_tagged_results("test_tag_del2", "test_path", self.log_printer) self.assertFalse(os.path.exists(path)) os.remove(none_path)
def test_tag_results(self): path = get_tag_path("test_tag_create", "test_path", self.log_printer) try: tag_results("test_tag_create", "test_path", {}, self.log_printer) results = load_tagged_results("test_tag_create", "test_path", self.log_printer) self.assertEqual(results, {}) finally: delete_tagged_results("test_tag_create", "test_path", self.log_printer) none_path = get_tag_path("None", "test_path", self.log_printer) tag_results("None", "test_path", {}, self.log_printer) self.assertFalse(os.path.exists(none_path)) results = load_tagged_results("None", "test_path", self.log_printer) self.assertEquals(results, None)
def test_tag_results(self): try: tag_results("test_tag", "test_path", {}) results = load_tagged_results("test_tag", "test_path") self.assertEqual(results, {}) finally: os.remove(get_tag_path("test_tag", "test_path"))
def test_tagging(self): with bear_test_module(), prepare_file(["\t#include <a>"], None) as (lines, filename): log_printer = LogPrinter(NullPrinter()) execute_coala( coala_ci.main, "coala-ci", "default", "-c", self.coafile, "-f", re.escape(filename), "-b", "SpaceConsistencyTestBear", "-S", "tag=test_tag", ) tag_path = get_tag_path("test_tag", self.unescaped_coafile, log_printer) self.assertTrue(os.path.exists(tag_path)) execute_coala( coala_ci.main, "coala-ci", "default", "-c", self.coafile, "-f", re.escape(filename), "-b", "SpaceConsistencyTestBear", "-S", "dtag=test_tag", ) self.assertFalse(os.path.exists(tag_path))
def test_tagging(self): execute_coala(coala_ci.main, "coala-ci", 'docs', "-S", "tag=test_tag", "-c", self.coafile) tag_path = get_tag_path("test_tag", self.unescaped_coafile) self.assertTrue(os.path.exists(tag_path)) execute_coala(coala_ci.main, "coala-ci", 'docs', "-S", "dtag=test_tag", "-c", self.coafile) self.assertFalse(os.path.exists(tag_path))
def test_permission_error(self, makedirs): makedirs.side_effect = PermissionError self.assertEqual(get_tag_path("a", "b", self.log_printer), None) tag_results("test_tag", "test_path", {}, self.log_printer) results = load_tagged_results("test_tag", "test_path", self.log_printer) self.assertEqual(results, None)
def test_permission_error(self): old_makedirs = os.makedirs os.makedirs = raise_permission_error self.assertEqual(get_tag_path("a", "b", self.log_printer), None) tag_results("test_tag", "test_path", {}, self.log_printer) results = load_tagged_results("test_tag", "test_path", self.log_printer) self.assertEqual(results, None) os.makedirs = old_makedirs
def test_permission_error(self): old_makedirs = os.makedirs os.makedirs = lambda *args, **kwargs: raise_error(PermissionError) self.assertEqual(get_tag_path("a", "b", self.log_printer), None) tag_results("test_tag", "test_path", {}, self.log_printer) results = load_tagged_results("test_tag", "test_path", self.log_printer) self.assertEqual(results, None) os.makedirs = old_makedirs
def test_get_tag_path(self): self.assertEqual(get_tag_path("a", "b", self.log_printer), get_tag_path("a", "b", self.log_printer)) self.assertNotEqual(get_tag_path("a", "b", self.log_printer), get_tag_path("a", "c", self.log_printer)) self.assertNotEqual(get_tag_path("a", "b", self.log_printer), get_tag_path("c", "b", self.log_printer))
def test_tagging(self): with bear_test_module(), \ prepare_file(["\t#include <a>"], None) as (lines, filename): log_printer = LogPrinter(NullPrinter()) execute_coala(coala_ci.main, "coala-ci", "default", "-c", self.coafile, "-f", re.escape(filename), "-b", "SpaceConsistencyTestBear", "-S", "tag=test_tag") tag_path = get_tag_path("test_tag", self.unescaped_coafile, log_printer) self.assertTrue(os.path.exists(tag_path)) execute_coala(coala_ci.main, "coala-ci", "default", "-c", self.coafile, "-f", re.escape(filename), "-b", "SpaceConsistencyTestBear", "-S", "dtag=test_tag") self.assertFalse(os.path.exists(tag_path))
def test_get_tag_path(self): self.assertEqual(get_tag_path("a", "b"), get_tag_path("a", "b")) self.assertNotEqual(get_tag_path("a", "b"), get_tag_path("a", "c")) self.assertNotEqual(get_tag_path("a", "b"), get_tag_path("c", "b"))
def test_delete_tagged_results_no_file(self): delete_tagged_results("test_tag", "test_path") self.assertFalse(os.path.exists(get_tag_path("test_tag", "test_path")))
def test_tagging(self): execute_coala_ci(("-S", "tag=test_tag", "-c", self.coafile)) tag_path = get_tag_path("test_tag", self.unescaped_coafile) self.assertTrue(os.path.exists(tag_path)) os.remove(tag_path)