Skip to content

Commit

Permalink
adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaosSokos committed Feb 18, 2025
1 parent f0f21fc commit f9c8472
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 12 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,40 @@ name: Publish Python Package

on:
push:
branches:
- main
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+a[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+b[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"

pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11" # Change as needed

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev] # Ensure pytest is in dev dependencies
- name: Run Tests
run: |
pytest --junitxml=pytest-report.xml --cov=my_package # Change `my_package`
- name: Upload Pytest Report
uses: actions/upload-artifact@v4
with:
name: pytest-report
path: pytest-report.xml
release-build:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')

steps:
- name: Checkout Repository
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ dependencies = [
"msgpack>=1.1.0",
"multidict>=6.0.4",
"pygments>=2.17.2",
"pytest>=8.3.4",
"pytest-asyncio>=0.25.3",
"requests>=2.31.0",
"rich>=13.7.0",
"textual==0.43.2",
Expand All @@ -46,4 +48,4 @@ packages = ["src/a10y"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
build-backend = "hatchling.build"
119 changes: 119 additions & 0 deletions src/a10y/a10y.tcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
Screen {
layout: vertical;
}

.box {
border: solid green;
min-width: 150;
}

.hide {
display: none;
}

#explanations-keys {
margin-left: 2;
}

Requests {
layout: grid;
grid-size: 5 5;
grid-columns: 0.7fr 1fr 1fr 1fr 1fr;
grid-rows: 1 3 3 3 3;
max-height: 15;
}

#request-title {
column-span: 5;
}

#nodes-container {
row-span: 4;
max-width: 24;
}

#nodes {
max-height: 9;
}

#nslc, #timeframe, #options, #send-request {
column-span: 4;
}

.request-label {
margin-top: 1;
}

.short-input {
width: 16;
}

AutoComplete {
max-height: 4;
max-width: 16;
margin-right: 3;
align: left top;
}

.date-input {
width: 27;
margin-right: 1;
}

#times {
width: 30;
}

#mergegaps {
max-width: 12;
}

#request-button {
margin: 0 5 0 5;
}

#post-file {
width: 50;
}

#status-container {
max-height: 5;
}

#status-collapse {
max-height: 10;
}

#error-results {
margin-left: 2;
}

ContentSwitcher {
margin-left: 2;
}

#info-bar {
background: $primary;
}

#lines {
height: auto;
}

#results-container {
max-height: 29;
height: auto;
}

#plain-container {
max-height: 30;
height: auto;
}

.result-item {
height: auto;
}

CursoredText {
margin-left: 2;
}
2 changes: 1 addition & 1 deletion src/a10y/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from textual.app import App
from textual.widgets import Header, Footer, Checkbox, Select, Input, Button, Collapsible, ContentSwitcher,Static,Label
from textual.containers import ScrollableContainer , Container, Horizontal
from widgets import Explanations, Requests, Results, Status, CursoredText # Import modular widgets
from a10y.widgets import Explanations, Requests, Results, Status, CursoredText # Import modular widgets
import requests
from datetime import datetime, timedelta
from textual.binding import Binding
Expand Down
2 changes: 1 addition & 1 deletion src/a10y/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import tomli
from datetime import datetime, timedelta
from app import AvailabilityUI # Import from same directory # Import the main UI application
from a10y.app import AvailabilityUI # Import from same directory # Import the main UI application


def parse_arguments():
Expand Down
Empty file added tests/__init__.py
Empty file.
41 changes: 41 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from a10y.app import AvailabilityUI
from textual.app import App
import pytest

@pytest.mark.asyncio
async def test_send_button():
"""Test clicking the send button."""


config = {
"default_starttime": "2024-01-01T00:00:00",
"default_endtime": "2024-01-02T00:00:00",
"default_mergegaps": "0.0",
"default_merge_samplerate": False,
"default_merge_quality": False,
"default_merge_overlap": False,
"default_quality_D": False,
"default_quality_R": False,
"default_quality_Q": False,
"default_quality_M": False,
"default_includerestricted": False,
"default_file": "",
}

app = AvailabilityUI(nodes_urls=[], routing = "https://www.orfeus-eu.org/eidaws/routing/1/query?", **config)

async with app.run_test() as pilot:

button = app.query_one("#request-button")
assert button is not None, "Button not found!"

# Click the send button
await pilot.click("#request-button")


assert button.disabled is True, "Button should be disabled after click"

await pilot.pause(2) # Waits for 500ms before checking the button

assert button.disabled is False, "Button should be re-enabled after request found"

0 comments on commit f9c8472

Please sign in to comment.