def test_page_index_with_process_all_restrictions(self):

        _status_server = None

        try:

            ruleset_configs = test_data.get_dummy_ruleset_configs(
                p_ruleset_config=test_data.
                RULESET_CONFIGS_USER1_ALL_RESTRICTIONS)
            _status_server = self.get_status_server_using_ruleset_configs(
                ruleset_configs)

            driver = self.get_selenium_driver()

            driver.get(
                _status_server.get_url(p_internal=False,
                                       p_rel_url=status_server.INDEX_REL_URL))
            assert "LittleBrother" in driver.title

            xpath = "//DIV[DIV[1] = 'User' and DIV[2] = 'Context' and DIV[12] = 'Reasons']"
            driver.find_element_by_xpath(xpath)

            driver.close()

        except Exception as e:
            raise e

        finally:
            _status_server.stop_server()
            _status_server.destroy()
    def test_process_statistics_get_empty_stat_infos(self):

        start_time = datetime.datetime.utcnow()
        rule_set_configs = test_data.get_dummy_ruleset_configs(
            p_ruleset_config=test_data.RULESET_CONFIGS_USER1_ALL_RESTRICTIONS)
        sis = process_statistics.get_empty_stat_infos(
            p_rule_set_configs=rule_set_configs,
            p_reference_time=start_time,
            p_max_lookback_in_days=5,
            p_min_activity_duration=30)

        self.assertIsNotNone(sis)
    def test_page_admin_with_process(self):

        _status_server = None

        try:
            ruleset_configs = test_data.get_dummy_ruleset_configs(
                p_ruleset_config=test_data.
                RULESET_CONFIGS_USER1_ALL_RESTRICTIONS)
            _status_server = self.get_status_server_using_ruleset_configs(
                ruleset_configs)

            driver = self.get_selenium_driver()

            # When we load the admin page the first time...
            driver.get(
                _status_server.get_url(p_internal=False,
                                       p_rel_url=status_server.ADMIN_REL_URL))
            assert "LittleBrother" in driver.title

            # ...we end up on the login page.
            elem = driver.find_element_by_name("username")
            elem.clear()
            elem.send_keys(ADMIN_USERNAME)

            elem = driver.find_element_by_name("password")
            elem.clear()
            elem.send_keys(ADMIN_PASSWORD)
            elem.send_keys(Keys.RETURN)

            # After logging in we are on the admin page
            xpath = "//FORM/DIV/DIV[DIV[1] = 'User' and DIV[2] = '']"
            driver.find_element_by_xpath(xpath)

            # The second we call the admin page.
            driver.get(
                _status_server.get_url(p_internal=False,
                                       p_rel_url=status_server.ADMIN_REL_URL))
            assert "LittleBrother" in driver.title

            # we are on the admin page right away...
            xpath = "//FORM/DIV/DIV[DIV[1] = 'User' and DIV[2] = '']"
            driver.find_element_by_xpath(xpath)

            driver.close()

        except Exception as e:
            raise e

        finally:
            _status_server.stop_server()
            _status_server.destroy()
Beispiel #4
0
    def test_process_statistics_get_empty_stat_infos(self):
        start_time = datetime.datetime.utcnow()
        rule_set_configs = test_data.get_dummy_ruleset_configs(
            p_ruleset_config=test_data.RULESET_CONFIGS_USER1_ALL_RESTRICTIONS)
        dummy_persistence = test_persistence.TestPersistence.create_dummy_persistence(
            self._logger)
        session_context = persistence.SessionContext(
            p_persistence=dummy_persistence)
        dummy_persistence.add_new_user(p_session_context=session_context,
                                       p_username=test_data.USER_1)
        migrator = db_migrations.DatabaseMigrations(
            p_logger=self._logger, p_persistence=dummy_persistence)
        migrator.migrate_ruleset_configs(p_ruleset_configs=rule_set_configs)
        sis = process_statistics.get_empty_stat_infos(
            p_user_map=dummy_persistence.user_map(session_context),
            p_reference_time=start_time,
            p_max_lookback_in_days=5,
            p_min_activity_duration=30)

        self.assertIsNotNone(sis)