added checks for php errors/warnings
This commit is contained in:
@@ -11,8 +11,8 @@ setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
require_once './lib/participoLib/participo.php';
|
||||
require_once './lib/participoLib/user.php';
|
||||
|
||||
require_once $config['basePath'] . '/config/cwsvJudo.config.php';
|
||||
require_once $config['basePath'] . '/config/phpcount.config.php';
|
||||
require_once $config["home"] . "/.local/cwsvJudo.config.php";
|
||||
// require_once $config['basePath'] . '/.local/phpcount.config.php';
|
||||
|
||||
dbConnector::connect(
|
||||
$cwsvJudoConfig['db']['host'],
|
||||
@@ -123,7 +123,7 @@ setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
private static $Types = [
|
||||
AttendanceType::Training => 'Training', AttendanceType::Excused => 'Entschuldigt', AttendanceType::Ill => 'Krank', AttendanceType::SpecialTraining => 'SonderTraining', AttendanceType::Competition => 'Wettkampf'
|
||||
];
|
||||
private static $NameOfMonth = [1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 4 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember'];
|
||||
private static $NameOfMonth = [1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember'];
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
||||
@@ -7,7 +7,7 @@ if (!isset($config)) {
|
||||
}
|
||||
|
||||
$config["home"] = "/home/cwsvjudo";
|
||||
$config["basePath"] = "/home/cwsvjudo/www";
|
||||
$config["basePath"] = "/home/cwsvjudo/httpdocs";
|
||||
$config["baseUrl"] = "http://cwsvjudo.bplaced.net";
|
||||
$config["ressourceUrl"] = "http://cwsvjudo.bplaced.net/ressourcen";
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
require_once './lib/api.php';
|
||||
|
||||
$basePath = $config['basePath'];
|
||||
require_once $basePath . '/config/cwsvJudo.config.php';
|
||||
require_once $config["home"] . "/.local/cwsvJudo.config.php";
|
||||
require_once $basePath . '/ressourcen/phpLib/parsedown/Parsedown.php';
|
||||
require_once $basePath . '/ressourcen/phpLib/Spyc/Spyc.php';
|
||||
|
||||
@@ -84,19 +84,9 @@ foreach ($years as $year) {?>
|
||||
<!-- List of Infos -->
|
||||
<div class="row" id="infoList">
|
||||
<?php
|
||||
$currentYear = (int)substr(basename($fileList[0]), 0, 4);
|
||||
echo('<h2 id="infoZettel-' . $currentYear . '">' . $currentYear . '</h2>');
|
||||
|
||||
foreach ($fileList as $file) {
|
||||
$thisYear = (int)substr(basename($file), 0, 4);
|
||||
if ($thisYear != $currentYear) {
|
||||
$currentYear = $thisYear;
|
||||
echo('<h2 id="infoZettel-' . $currentYear . '">' . $currentYear . '</h2>');
|
||||
}
|
||||
|
||||
// get a list of all infoZettel
|
||||
$fileList = glob($basePath . '/infoZettel/*.md');
|
||||
rsort($fileList);
|
||||
if (!empty($fileList)){
|
||||
$currentYear = (int)substr(basename($fileList[0]), 0, 4);
|
||||
echo('<h2 id="infoZettel-' . $currentYear . '">' . $currentYear . '</h2>');
|
||||
|
||||
foreach ($fileList as $file) {
|
||||
$thisYear = (int)substr(basename($file), 0, 4);
|
||||
@@ -105,18 +95,31 @@ foreach ($fileList as $file) {
|
||||
echo('<h2 id="infoZettel-' . $currentYear . '">' . $currentYear . '</h2>');
|
||||
}
|
||||
|
||||
$infoZettel = loadMarkdownFile($file);
|
||||
echo(
|
||||
AppCard::fromArray([
|
||||
'title' => $infoZettel['yaml']['title'],
|
||||
'description' => Parsedown::instance()->text($infoZettel['mdText']),
|
||||
])->htmlCode(['extraClass' => 'parsedownCard'])
|
||||
);
|
||||
} ?>
|
||||
// get a list of all infoZettel
|
||||
$fileList = glob($basePath . '/infoZettel/*.md');
|
||||
rsort($fileList);
|
||||
|
||||
foreach ($fileList as $file) {
|
||||
$thisYear = (int)substr(basename($file), 0, 4);
|
||||
if ($thisYear != $currentYear) {
|
||||
$currentYear = $thisYear;
|
||||
echo('<h2 id="infoZettel-' . $currentYear . '">' . $currentYear . '</h2>');
|
||||
}
|
||||
|
||||
$infoZettel = loadMarkdownFile($file);
|
||||
echo(
|
||||
AppCard::fromArray([
|
||||
'title' => $infoZettel['yaml']['title'],
|
||||
'description' => Parsedown::instance()->text($infoZettel['mdText']),
|
||||
])->htmlCode(['extraClass' => 'parsedownCard'])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo("Keine Infos gefunden!");
|
||||
} ?>
|
||||
</div><!-- End of Infos -->
|
||||
</main>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,8 +9,8 @@ require_once './lib/participoLib/participo.php';
|
||||
require_once './lib/db.php';
|
||||
require_once './lib/api.php';
|
||||
|
||||
require_once $config['basePath'] . '/config/cwsvJudo.config.php';
|
||||
require_once $config['basePath'] . '/config/phpcount.config.php';
|
||||
require_once $config["home"] . "/.local/cwsvJudo.config.php";
|
||||
// require_once $config['basePath'] . '/config/phpcount.config.php';
|
||||
|
||||
dbConnector::connect(
|
||||
$cwsvJudoConfig['db']['host'],
|
||||
|
||||
@@ -22,6 +22,9 @@ services:
|
||||
# ressourcen
|
||||
- /home/marko/cwsvJudo/submodules/materialize/dist:/home/cwsvjudo/httpdocs/ressourcen/materializeCss
|
||||
- /home/marko/cwsvJudo/homepage/cwsvJudo/build/graphiken:/home/cwsvjudo/httpdocs/ressourcen/graphiken
|
||||
# libs
|
||||
- /home/marko/cwsvJudo/submodules/parsedown:/home/cwsvjudo/httpdocs/ressourcen/phpLib/parsedown
|
||||
- /home/marko/cwsvJudo/submodules/spyc:/home/cwsvjudo/httpdocs/ressourcen/phpLib/Spyc
|
||||
# php and extensions
|
||||
php:
|
||||
# use pre-build image from docker..
|
||||
@@ -37,6 +40,9 @@ services:
|
||||
- ./cwsvjudo@bplaced/www/participo:/home/cwsvjudo/httpdocs/participo
|
||||
# the apps config files
|
||||
- ./config-heliohost/cwsvJudo.config.php:/home/cwsvjudo/.local/cwsvJudo.config.php
|
||||
# libs
|
||||
- /home/marko/cwsvJudo/submodules/parsedown/Parsedown.php:/home/cwsvjudo/httpdocs/ressourcen/phpLib/parsedown/Parsedown.php
|
||||
- /home/marko/cwsvJudo/submodules/spyc/Spyc.php:/home/cwsvjudo/httpdocs/ressourcen/phpLib/Spyc/Spyc.php
|
||||
# @todo Maybe use postgre instead?
|
||||
database:
|
||||
image: mariadb:latest
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from selenium import webdriver
|
||||
import logging
|
||||
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.remote.webdriver import WebDriver
|
||||
|
||||
|
||||
def load_config(config_path: str = "config.toml"):
|
||||
@@ -9,20 +9,16 @@ def load_config(config_path: str = "config.toml"):
|
||||
with open(file=config_path, mode="rb") as config_file:
|
||||
return load(config_file)
|
||||
|
||||
def login(driver: WebDriver, username: str, password:str):
|
||||
driver.find_element(by=By.ID, value="username").send_keys(username)
|
||||
driver.find_element(by=By.ID, value="password").send_keys(password)
|
||||
driver.find_element(by=By.TAG_NAME, value="form").submit()
|
||||
|
||||
class Participo:
|
||||
def __init__(self) -> None:
|
||||
from selenium.webdriver import FirefoxOptions
|
||||
from selenium.webdriver import Firefox, FirefoxOptions
|
||||
|
||||
options = FirefoxOptions()
|
||||
# options.add_argument("-headless")
|
||||
options.add_argument("-headless")
|
||||
|
||||
self.config = load_config()
|
||||
self.driver = webdriver.Firefox(options=options)
|
||||
self.driver = Firefox(options=options)
|
||||
|
||||
self.delay = 5
|
||||
|
||||
@@ -36,21 +32,41 @@ class Participo:
|
||||
def get_home(self):
|
||||
self.driver.get(url=self.config["url"]["home"])
|
||||
|
||||
def load_section(self, section: str):
|
||||
section_url = "/".join((self.config["url"]["home"], section))
|
||||
self.driver.get(url=section_url)
|
||||
|
||||
def login(self):
|
||||
credentials = self.config["credentials"]
|
||||
login(driver=self.driver, username=credentials["username"], password=credentials["password"])
|
||||
|
||||
self.driver.find_element(by=By.ID, value="username").send_keys(
|
||||
credentials["username"]
|
||||
)
|
||||
self.driver.find_element(by=By.ID, value="password").send_keys(
|
||||
credentials["password"]
|
||||
)
|
||||
self.driver.find_element(by=By.TAG_NAME, value="form").submit()
|
||||
|
||||
def check_login(self):
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
return self.check_for(By.LINK_TEXT, "Logout")
|
||||
|
||||
def check_for_xdebug_msgs(self):
|
||||
classes = ("xdebug-error", "xe-warning")
|
||||
|
||||
return any((self.check_for(By.CLASS_NAME, c) for c in classes))
|
||||
|
||||
def check_for(self, selector: str, value: str) -> bool:
|
||||
from selenium.common.exceptions import NoSuchElementException, TimeoutException
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
||||
try:
|
||||
logoutButton = WebDriverWait(driver=self.driver, timeout=self.delay).until(
|
||||
EC.presence_of_element_located(
|
||||
locator=(By.LINK_TEXT, "Logout")
|
||||
)
|
||||
_ = WebDriverWait(driver=self.driver, timeout=self.delay).until(
|
||||
EC.presence_of_element_located(locator=(selector, value))
|
||||
)
|
||||
return True
|
||||
except NoSuchElementException:
|
||||
logging.info(f"No such element ({selector}, {value})")
|
||||
return False
|
||||
except TimeoutException:
|
||||
return False
|
||||
|
||||
@@ -2,14 +2,33 @@
|
||||
|
||||
# testing the participo app
|
||||
import unittest
|
||||
import logging
|
||||
|
||||
from helper import Participo
|
||||
|
||||
|
||||
class TestParticipo(unittest.TestCase):
|
||||
def test_login(self):
|
||||
with Participo() as participo:
|
||||
participo.login()
|
||||
self.assertTrue(participo.check_login(), "Login failed")
|
||||
|
||||
def test_sub_pages(self):
|
||||
with Participo() as participo:
|
||||
participo.login()
|
||||
self.assertTrue(participo.check_login())
|
||||
|
||||
sections = ("events", "infoZettel", "attendance", "user")
|
||||
for section in sections:
|
||||
with self.subTest(msg=f"- {section}"):
|
||||
participo.load_section(section=section)
|
||||
|
||||
self.assertFalse(
|
||||
expr=participo.check_for_xdebug_msgs(),
|
||||
msg=f"php errors on section {section}",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user