コード例 #1
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
class TestRepositoryTest(TestCase):

    def setUp(self):
        self.file_system = InMemoryFileSystem()
        self.repository = FileBasedTestRepository(
            self.file_system,
            Path.fromText("tests"),
            YamlCodec())

    def test_do_not_found_test_that_do_not_exist(self):
        test_cases = self._fetch_all_tests()
        self.assertEqual(0, len(test_cases))

    def test_found_one_test_if_only_one_yml_exists(self):
        self._create_file("tests/test.yml", YamlTest.with_latex_code())
        test_cases = self.repository.fetch_all()
        self._verify(test_cases)

    def test_found_one_test_if_only_one_yaml_exists(self):
        self._create_file("tests/test.yaml", YamlTest.with_latex_code())
        test_cases = self.repository.fetch_all()
        self._verify(test_cases)

    def test_ignore_files_that_are_not_yaml(self):
        self._create_file("tests/test.txt", YamlTest.with_latex_code())
        test_cases = self._fetch_all_tests()
        self.assertEqual(0, len(test_cases))

    def test_spot_files_hidden_in_sub_directories(self):
        self._create_file(
            "tests/sub_dir/test_2.yml",
            YamlTest.with_latex_code())
        test_cases = self._fetch_all_tests()
        self._verify(test_cases)

    def _verify(self, test_cases):
        self.assertEqual(1, len(test_cases))
        expected = FlapTestCase(
            "test 1",
            a_project().with_main_file(self.LATEX_CODE).build(),
            a_project().with_merged_file(self.LATEX_CODE).build())
        self.assertEqual(expected, test_cases[0])

    LATEX_CODE = ("\\documentclass{article}\n"
                  "\\begin{document}\n"
                  "  This is a simple \\LaTeX document!\n"
                  "\\end{document}")

    def _fetch_all_tests(self):
        return self.repository.fetch_all()

    def _create_file(self, path, content):
        self.file_system.create_file(Path.fromText(path), content)
コード例 #2
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
class TestRepositoryTest(TestCase):

    def setUp(self):
        self.file_system = InMemoryFileSystem()
        self.repository = FileBasedTestRepository(
            self.file_system,
            Path.fromText("tests"),
            YamlCodec())

    def test_do_not_found_test_that_do_not_exist(self):
        test_cases = self._fetch_all_tests()
        self.assertEqual(0, len(test_cases))

    def test_found_one_test_if_only_one_yml_exists(self):
        self._create_file("tests/test.yml", YamlTest.with_latex_code())
        test_cases = self.repository.fetch_all()
        self._verify(test_cases)

    def test_found_one_test_if_only_one_yaml_exists(self):
        self._create_file("tests/test.yaml", YamlTest.with_latex_code())
        test_cases = self.repository.fetch_all()
        self._verify(test_cases)

    def test_ignore_files_that_are_not_yaml(self):
        self._create_file("tests/test.txt", YamlTest.with_latex_code())
        test_cases = self._fetch_all_tests()
        self.assertEqual(0, len(test_cases))

    def test_spot_files_hidden_in_sub_directories(self):
        self._create_file("tests/sub_dir/test_2.yml", YamlTest.with_latex_code())
        test_cases = self._fetch_all_tests()
        self._verify(test_cases)

    def _verify(self, test_cases):
        self.assertEqual(1, len(test_cases))
        expected = FlapTestCase(
            "test 1",
            a_project().with_main_file(self.LATEX_CODE).build(),
            a_project().with_merged_file(self.LATEX_CODE).build())
        self.assertEqual(expected, test_cases[0])

    LATEX_CODE = ("\\documentclass{article}\n"
                  "\\begin{document}\n"
                  "  This is a simple \\LaTeX document!\n"
                  "\\end{document}")

    def _fetch_all_tests(self):
        return self.repository.fetch_all()

    def _create_file(self, path, content):
        self.file_system.create_file(Path.fromText(path), content)
コード例 #3
0
ファイル: __init__.py プロジェクト: alcrene/flap
def load_tests(loader, tests, pattern):
    file_system = OSFileSystem()
    repository = FileBasedTestRepository(file_system, Path.fromText("tests/acceptance/scenarios"), YamlCodec())
    runner = EndToEndRunner(file_system)
    generate = Generator(repository, runner)
    suite = TestSuite()
    tests = loader.loadTestsFromTestCase(generate.test_class())
    suite.addTests(tests)
    return suite
コード例 #4
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def setUp(self):
     self.file_system = InMemoryFileSystem()
     self.repository = FileBasedTestRepository(
         self.file_system,
         Path.fromText("tests"),
         YamlCodec())
コード例 #5
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def setUp(self):
     self.file_system = InMemoryFileSystem()
     self.repository = FileBasedTestRepository(
         self.file_system,
         Path.fromText("tests"),
         YamlCodec())