Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 29 additions & 36 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,62 @@
on:
push:
branches:
- master
- master
pull_request:
branches:
- master
- master

name: Test

jobs:
test:
runs-on: ubuntu-20.04
needs: flake8-lint
runs-on: ubuntu-latest
services:
selenium:
image: selenium/standalone-chrome
name: Test
strategy:
matrix:
python-version: [ "3.6", "3.7", "3.8", "3.9", "3.10", "3.11" ]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v2
- name: Setup python
id: test
uses: actions/setup-python@v1
with:
python-version: "${{ matrix.python-version }}"
- name: Install dependencies
run: pip install -r requirements-test.txt
- name: Test
run: pytest tests -vv
- uses: actions/checkout@v4
- name: Setup python
id: test
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
- name: Install dependencies
run: pip install -r requirements-test.txt
- name: Test
run: pytest tests -vv

coverage:
runs-on: ubuntu-latest
needs: flake8-lint
services:
selenium:
image: selenium/standalone-chrome
steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.7
- name: Install dependencies
run: pip install -r requirements-test.txt
- name: Generate coverage report
run: pytest --cov=selenium_datatable --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
directory: ./coverage/reports/
fail_ci_if_error: true
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
path_to_write_report: ./coverage/codecov_report.txt
verbose: true
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.14
- name: Install dependencies
run: pip install -r requirements-test.txt
- name: Generate coverage report
run: pytest --cov=selenium_datatable --junitxml=junit.xml -o junit_family=legacy
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

flake8-lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v2
with:
Expand Down
12 changes: 6 additions & 6 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Flask==2.0.3
pytest==7.0.1
pytest-cov==3.0.0
requests==2.27.1
selenium==3.141.0
Werkzeug==2.0.2
Flask>=2.0.3
pytest>=7.0.1
pytest-cov>=3.0.0
requests>=2.27.1
selenium>=3.141.0
Werkzeug>=2.0.2
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = A small library for simplifying a table object in selenium
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/fundakol/selenium_datatable
python_requires = >=3.6
python_requires = >=3.9
keywords = selenium table data-table testing
classifiers =
Development Status :: 5 - Production/Stable
Expand Down
33 changes: 18 additions & 15 deletions tests/mock_http_server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from threading import Thread
from uuid import uuid4

import requests
from flask import Flask, render_template

from flask import Flask, jsonify, render_template
from werkzeug.serving import make_server

app = Flask(__name__)

Expand All @@ -11,27 +11,30 @@
def index():
return render_template('index.html')

HOST = '127.0.0.1'

class MockServer(Thread):

def __init__(self, port=5000):
super().__init__()
self.port = port
self.app = app
self.url = f'http://localhost:{self.port}'

self.app.add_url_rule('/shutdown', view_func=self._shutdown_server)

def _shutdown_server(self):
from flask import request
if 'werkzeug.server.shutdown' not in request.environ:
raise RuntimeError('Not running the development server')
request.environ['werkzeug.server.shutdown']()
return 'Server shutting down...'
self.server = make_server(HOST, self.port, self.app)
self.url = f'http://{HOST}:{self.port}'

def shutdown_server(self):
requests.get(f'{self.url}/shutdown')
self.server.shutdown()
self.join()

def add_callback_response(self, url, callback, methods=('GET',)):
callback.__name__ = str(uuid4()) # change name of method to mitigate flask exception
self.app.add_url_rule(url, view_func=callback, methods=methods)

def add_json_response(self, url, serializable, methods=('GET',)):
def callback():
return jsonify(serializable)

self.add_callback_response(url, callback, methods=methods)

def run(self):
self.app.run(port=self.port)
self.server.serve_forever()