Skip to content

Commit

Permalink
Merge pull request #7 from erral/erral-tests
Browse files Browse the repository at this point in the history
Create python-app.yml
  • Loading branch information
erral authored Sep 3, 2024
2 parents 20ee0f6 + e0fc06a commit 902763e
Show file tree
Hide file tree
Showing 8 changed files with 2,949 additions and 380 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -e .
pip install -e .[test]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 fideparser --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 fideparser --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest tests
2 changes: 1 addition & 1 deletion fideparser/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
class InvalideFileFormat(Exception):
""" Raised when importing an incorrect binary file """
"""Raised when importing an incorrect binary file"""
4 changes: 2 additions & 2 deletions fideparser/ratingperiod.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __eq__(self, other):
return fields_equal and tournaments_equal

def save(self):
""" import the data from FIDE site """
"""import the data from FIDE site"""
url = BASE_URL % {"country": self.country, "period": self.period}
print("Getting period data...")
sock = requests.get(url)
Expand Down Expand Up @@ -70,7 +70,7 @@ def load_from_file(self, filepath):
self.fieldnames = self.fieldnames.union(tournament.data.keys())

def export(self, filename, format="binary"):
""" return the saved data in a structured way """
"""return the saved data in a structured way"""
if format == "binary":
self.export_binary(filename)
elif format == "json":
Expand Down
2 changes: 1 addition & 1 deletion fideparser/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class InvalidReportException(Exception):


class Report(object):
""" Extract data from the tournament report"""
"""Extract data from the tournament report"""

def __init__(self, link):
self.link = link
Expand Down
2 changes: 1 addition & 1 deletion fideparser/tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import requests


BASE_URL = u"https://ratings.fide.com"
BASE_URL = "https://ratings.fide.com"


class Tournament(object):
Expand Down
3,275 changes: 2,902 additions & 373 deletions tests/fide_responses/arbiter.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/test_arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def test_arbiter_data(self):
responses.add(responses.GET, arbiter_url, body=contents)

r = Arbiter(arbiter_url)
self.assertIn("FIDE title", r.data)
self.assertIn("FIDE title:", r.data)
2 changes: 1 addition & 1 deletion tests/test_tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_tournament(self):
def test_tournament_with_arbiter_data(self):
tournament_url_value = "/tournament_details.phtml?event=186590"
r = Tournament(tournament_url_value, extract_arbiter_data=True)
self.assertIn("arbiter1_name", r.data)
self.assertIn("Chief Arbiter", r.data)

@responses.activate
def test_tournament_with_report_data(self):
Expand Down

0 comments on commit 902763e

Please sign in to comment.