Esempio n. 1
0
    def test_update_counts(self):
        """Tell our SQLReporter to update its counts, and check that it does."""
        conn = self.reporter.conn

        (build,) = list(conn.execute(Builds.select()))

        assert_equal(build['method_count'], None)

        self.reporter.test_counts(3, 50)
        (updated_build,) = list(conn.execute(Builds.select()))

        assert_equal(updated_build['method_count'], 50)
Esempio n. 2
0
    def test_update_counts(self):
        """Tell our SQLReporter to update its counts, and check that it does."""
        conn = self.reporter.conn

        (build, ) = list(conn.execute(Builds.select()))

        assert_equal(build['method_count'], None)

        self.reporter.test_counts(3, 50)
        (updated_build, ) = list(conn.execute(Builds.select()))

        assert_equal(updated_build['method_count'], 50)
Esempio n. 3
0
    def test_integration(self):
        """Run a runner with self.reporter as a test reporter, and verify a bunch of stuff."""
        runner = TestRunner(DummyTestCase, test_reporters=[self.reporter])
        conn = self.reporter.conn

        # We're creating a new in-memory database in make_reporter, so we don't need to worry about rows from previous tests.
        (build, ) = list(conn.execute(Builds.select()))

        assert_equal(build['buildname'], 'a_build_name')
        assert_equal(build['branch'], 'a_branch_name')
        assert_equal(build['revision'],
                     'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef')

        # Method count should be None until we discover (which is part of running)
        assert_equal(build['method_count'], None)
        # End time should be None until we run.
        assert_equal(build['end_time'], None)

        assert runner.run()

        # Now that we've run the tests, get the build row again and check to see that things are updated.
        (updated_build, ) = list(conn.execute(Builds.select()))

        for key in updated_build.keys():
            if key not in ('end_time', 'run_time', 'method_count'):
                assert_equal(build[key], updated_build[key])

        assert_gt(updated_build['run_time'], 0)
        assert_in_range(updated_build['end_time'], 0, time.time())
        assert_equal(updated_build['method_count'], 2)

        # The discovery_failure column should exist and be False.
        assert 'discovery_failure' in build
        assert_equal(build['discovery_failure'], False)

        # Check that we have one failure and one pass, and that they're the right tests.
        test_results = list(
            conn.execute(
                SA.select(columns=TestResults.columns + Tests.columns,
                          from_obj=TestResults.join(
                              Tests, TestResults.c.test == Tests.c.id))))

        assert_equal(len(test_results), 2)
        (passed_test, ) = [r for r in test_results if not r['failure']]
        (failed_test, ) = [r for r in test_results if r['failure']]

        assert_equal(passed_test['method_name'], 'test_pass')
        assert_equal(failed_test['method_name'], 'test_fail')
Esempio n. 4
0
    def test_integration(self):
        """Run a runner with self.reporter as a test reporter, and verify a bunch of stuff."""
        runner = TestRunner(DummyTestCase, test_reporters=[self.reporter])
        conn = self.reporter.conn

        # We're creating a new in-memory database in make_reporter, so we don't need to worry about rows from previous tests.
        (build,) = list(conn.execute(Builds.select()))

        assert_equal(build['buildname'], 'a_build_name')
        assert_equal(build['branch'], 'a_branch_name')
        assert_equal(build['revision'], 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef')

        # Method count should be None until we discover (which is part of running)
        assert_equal(build['method_count'], None)
        # End time should be None until we run.
        assert_equal(build['end_time'], None)

        assert runner.run()

        # Now that we've run the tests, get the build row again and check to see that things are updated.
        (updated_build,) = list(conn.execute(Builds.select()))

        for key in updated_build.keys():
            if key not in ('end_time', 'run_time', 'method_count'):
                assert_equal(build[key], updated_build[key])

        assert_gt(updated_build['run_time'], 0)
        assert_in_range(updated_build['end_time'], 0, time.time())
        assert_equal(updated_build['method_count'], 2)

        # The discovery_failure column should exist and be False.
        assert 'discovery_failure' in build
        assert_equal(build['discovery_failure'], False)

        # Check that we have one failure and one pass, and that they're the right tests.
        test_results = list(conn.execute(SA.select(
            columns=TestResults.columns + Tests.columns,
            from_obj=TestResults.join(Tests, TestResults.c.test == Tests.c.id)
        )))

        assert_equal(len(test_results), 2)
        (passed_test,) = [r for r in test_results if not r['failure']]
        (failed_test,) = [r for r in test_results if r['failure']]

        assert_equal(passed_test['method_name'], 'test_pass')
        assert_equal(failed_test['method_name'], 'test_fail')
Esempio n. 5
0
    def test_sql_reporter_sets_discovery_failure_flag(self):
        runner = TestRunner(self.broken_import_module, test_reporters=[self.reporter])
        runner.run()

        conn = self.reporter.conn
        (build,) = list(conn.execute(Builds.select()))

        assert_equal(build['discovery_failure'], True)
Esempio n. 6
0
    def test_sql_reporter_sets_discovery_failure_flag(self):
        runner = TestRunner(self.broken_import_module,
                            test_reporters=[self.reporter])
        runner.run()

        conn = self.reporter.conn
        (build, ) = list(conn.execute(Builds.select()))

        assert_equal(build['discovery_failure'], True)
        assert_equal(build['method_count'], 0)