def test_deregister_program(self):
        # Ensure that results and registrants are empty
        results = database_engine.get_current_results()
        registrants = database_engine.all_registrants()
        self.assertTrue(len(results) == 0)
        self.assertTrue(len(list(registrants)) == 0)

        # Register a program
        passing = testing_framework_test.TestTestingFramework.pass_test
        database_engine.register_program(passing[0], passing[1], passing[2],
                                         passing[3])

        # Ensure program is registered
        registrants = database_engine.all_registrants()
        self.assertTrue(len(list(registrants)) == 1)
        results = database_engine.get_current_results()
        if len(results) == 0:
            self.fail('Results should contain something')

        # Deregister
        database_engine.deregister_program(1)

        # Check that results and registrants empty
        results = database_engine.get_current_results()
        registrants = database_engine.all_registrants()
        self.assertTrue(len(results) == 0)
        self.assertTrue(len(list(registrants)) == 0)
Ejemplo n.º 2
0
    def test_individual_test(self):
        # Register Multiple tests
        failure = TestTestingFramework.fail_test
        passing = TestTestingFramework.pass_test
        database_engine.register_program(failure[0], failure[1], failure[2],
                                         failure[3])
        database_engine.register_program(passing[0], passing[1], passing[2],
                                         passing[3])

        # Execute only the passing test
        testing_framework.execute_individual_test(2)

        # Expect that only the passing test executed
        results = database_engine.get_current_results()
        if len(results) == 0:
            self.fail('Results should contain something')
        with database_engine.connect() as session:
            exec_rec = session.query(models.ExecutionRecord).order_by(
                models.ExecutionRecord.timestamp.desc())[0]
            for test in results:
                if test[1].last_execution_id == exec_rec.id:
                    self.assertTrue(test[0].name == passing[0])
                elif test[0].name == passing[0]:
                    self.fail(
                        'The passing record should be the most recent execution'
                    )
Ejemplo n.º 3
0
    def test_multiple_tests(self):
        # Register multiple tests
        failure = TestTestingFramework.fail_test
        passing = TestTestingFramework.pass_test
        database_engine.register_program(failure[0], failure[1], failure[2],
                                         failure[3])
        database_engine.register_program(passing[0], passing[1], passing[2],
                                         passing[3])
        database_engine.register_program(passing[0], passing[1], passing[2],
                                         passing[3])
        database_engine.register_program(failure[0], failure[1], failure[2],
                                         failure[3])

        # Execute all tests
        testing_framework.execute_tests()

        # Get expected results
        results = database_engine.get_current_results()
        if len(results) == 0:
            self.fail('Results should contain something')
        for test in results:
            if test[0].name == passing[0]:
                self.assertTrue(test[1].last_execution_id is
                                test[1].last_successful_execution_id)
            else:
                self.assertTrue(test[1].last_execution_id
                                is not test[1].last_successful_execution_id)
Ejemplo n.º 4
0
    def test_execute_failed_tests(self):
        # Register multiple tests
        failure = TestTestingFramework.fail_test
        passing = TestTestingFramework.pass_test
        database_engine.register_program(failure[0], failure[1], failure[2],
                                         failure[3])
        database_engine.register_program(passing[0], passing[1], passing[2],
                                         passing[3])
        database_engine.register_program(passing[0], passing[1], passing[2],
                                         passing[3])
        database_engine.register_program(failure[0], failure[1], failure[2],
                                         failure[3])

        # Execute all tests to get the ones that have failed
        testing_framework.execute_tests()

        # Execute only the failed tests
        testing_framework.execute_failed_tests()

        results = database_engine.get_current_results()
        if len(results) == 0:
            self.fail('Results should contain something')
        with database_engine.connect() as session:
            exec_rec = session.query(models.ExecutionRecord).order_by(
                models.ExecutionRecord.timestamp.desc())[0]
            for test in results:
                if test[0].name == passing[0]:
                    self.assertFalse(test[1].last_execution_id == exec_rec.id)
                else:
                    self.assertTrue(test[1].last_execution_id == exec_rec.id)
Ejemplo n.º 5
0
    def test_passing_test_passes(self):
        # Register a testss that will pass
        test = TestTestingFramework.pass_test
        database_engine.register_program(test[0], test[1], test[2], test[3])

        # Execute the testss
        testing_framework.execute_tests()

        # Confirm that the testss passes by checking failure records
        registrants = []
        for tests in database_engine.get_current_results():
            registrants.append(tests[0])
        self.assertTrue(
            registrants.__contains__(database_engine.get_registrant(1)))
        self.assertFalse(
            database_engine.get_failure_registrants().__contains__(
                database_engine.get_registrant(1)))
    def test_execution_when_registered(self):
        # Register a program
        passing = testing_framework_test.TestTestingFramework.pass_test
        database_engine.register_program(passing[0], passing[1], passing[2],
                                         passing[3])

        # Check that the program executed
        results = database_engine.get_current_results()
        if len(results) == 0:
            self.fail('Results should contain something')
        for test in results:
            self.assertTrue(test[0].name == passing[0])
            self.assertTrue(test[1].last_execution_id is
                            test[1].last_successful_execution_id)

        # Delete the registrant
        database_engine.deregister_program(1)
Ejemplo n.º 7
0
def index():
    """The index page of the web app displays several tables detailing registrants and their results"""
    # instantiate the form object with request data
    form = forms.RegistrantForm(request.form)
    if request.method == "POST": # handle new registration
        if form.validate():
            database_engine.register_program(
                form.name.data,
                form.path.data,
                form.command.data,
                form.author.data,
            )
            return redirect(url_for('index'))
    return flask.render_template(
        'index.html',
        context=dict(
            current_version=testing_framework.get_current_os_version(),
            registrants=database_engine.all_registrants(),
            test_results=database_engine.get_current_results(),
            form=form))
 def test_get_current_results_returns_nothing_with_no_executed_tests(self):
     self.assertTrue(len(database_engine.get_current_results()) == 0)