-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support timezone when CUPS is from Canary Islands (#28)
* Fix canary timezon and add tests * Add GitHub Actions workflow to run tests * Fix unittest run * Update dependencies * Publish unittest results * Fix publish test results --------- Co-authored-by: xavier <[email protected]>
- Loading branch information
1 parent
f0b42e2
commit 251bad7
Showing
6 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Python tests | ||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: [ "2.7" ] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
- name: Set up Python ${{ matrix.python-version }} | ||
if: matrix.python-version != '2.7' | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up Python 2.7 | ||
if: matrix.python-version == '2.7' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y python2.7 python2.7-dev | ||
sudo ln -sf python2.7 /usr/bin/python | ||
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py | ||
python get-pip.py | ||
rm get-pip.py | ||
pip install --upgrade pip setuptools wheel | ||
- name: Install dependencies | ||
run: | | ||
cd ${{github.workspace}} | ||
pip install -e . | ||
pip install unittest-xml-reporting | ||
- name: Run Tests | ||
run: | | ||
cd ${{github.workspace}} | ||
python -m xmlrunner tests -o test-reports | ||
- name: Publish Unit Test Results | ||
if: (success() || failure()) && matrix.python-version == '2.7' && github.event_name == 'pull_request' | ||
uses: EnricoMi/publish-unit-test-result-action@v1 | ||
with: | ||
files: ${{github.workspace}}/test-reports/*.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ pymongo<3.0 | |
osconf | ||
marshmallow>=2.13.5 | ||
click | ||
pytz | ||
psycopg2-binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import unittest | ||
from datetime import datetime | ||
from pytz import timezone | ||
|
||
class CchloaderBackendTimescaleTest(unittest.TestCase): | ||
|
||
def test__get_as_utc_timestamp__peninsula(self): | ||
from cchloader.backends.timescaledb import get_as_utc_timestamp | ||
|
||
result_winter = get_as_utc_timestamp(datetime(2023,1,1), 'ES123456748798', 0) | ||
result_summer = get_as_utc_timestamp(datetime(2023,10,1), 'ES123456748798', 1) | ||
|
||
self.assertEqual(datetime(2022, 12, 31, 23, 0, tzinfo=timezone('utc')), result_winter) | ||
self.assertEqual(datetime(2023, 9, 30, 22, 0, tzinfo=timezone('utc')), result_summer) | ||
|
||
def test__get_as_utc_timestamp__canary_islands(self): | ||
from cchloader.backends.timescaledb import get_as_utc_timestamp | ||
|
||
result_winter = get_as_utc_timestamp(datetime(2023,1,1), 'ES0031656748798', 0) | ||
result_summer = get_as_utc_timestamp(datetime(2023,10,2), 'ES0031656748798', 1) | ||
|
||
self.assertEqual(datetime(2023, 1, 1, 0, 0, tzinfo=timezone('utc')), result_winter) | ||
self.assertEqual(datetime(2023, 10, 1, 23, 0, tzinfo=timezone('utc')), result_summer) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|