Skip to content

Commit

Permalink
First test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhollmann committed Dec 27, 2021
1 parent a5c0c98 commit 22f9ebd
Show file tree
Hide file tree
Showing 9 changed files with 398 additions and 10 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Tests

on:
push:
paths-ignore:
- 'docs/**'
branches:
- main
pull_request:
paths-ignore:
- 'docs/**'
branches:
- '**'

concurrency:
group: tests-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
tests:
name: ${{ matrix.os }} / ${{ matrix.python-version }} ${{ matrix.suffix }}
runs-on: ${{ matrix.image }}
strategy:
matrix:
os: [Ubuntu, macOS, Windows]
python-version: ["3.7", "3.8", "3.9", "3.10"]
include:
- os: Ubuntu
image: ubuntu-latest
- os: Windows
image: windows-2022
- os: macOS
image: macos-11
fail-fast: false
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y ${{ matrix.bootstrap-args }}
- name: Update PATH
if: ${{ matrix.os != 'Windows' }}
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Update Path for Windows
if: ${{ matrix.os == 'Windows' }}
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH

- name: Configure poetry
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v2
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Install dependencies
run: poetry install

- name: Run pytest
run: poetry run coverage run -m pytest -p no:sugar

- name: Upload coverage data to coveralls.io
run: poetry run coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
COVERALLS_PARALLEL: true
279 changes: 278 additions & 1 deletion poetry.lock

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,25 @@ requests = "^2.0"

[tool.poetry.dev-dependencies]
black = "^21.12b0"
isort = "^5.10.1"
coveralls = "^3.3.1"
pytest = "^6.2.5"
pytest-sugar = "^0.9.4"

[tool.black]
target-version = ['py37']

[tool.isort]
py_version = 37
profile = "black"
force_single_line = true
combine_as_imports = true
lines_after_imports = 2
src_paths = ["src", "tests"]

[tool.coverage.run]
source = ["src"]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
5 changes: 3 additions & 2 deletions src/blueskyapi/client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import requests
import json
import pandas as pd
from datetime import datetime

import pandas as pd
import requests

from blueskyapi import default_config
from blueskyapi import errors

Expand Down
2 changes: 1 addition & 1 deletion src/blueskyapi/default_config.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
api_key = None
base_url = "https://api.blueskyapi.io"
api_key = None
3 changes: 2 additions & 1 deletion src/blueskyapi/errors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from requests import codes
import json

from requests import codes


class Error(Exception):
pass
Expand Down
5 changes: 0 additions & 5 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,3 @@
min_prediction_moment="2021-06-01 00:00",
)
print(d)


import ptpython.repl

ptpython.repl.embed(globals(), locals())
7 changes: 7 additions & 0 deletions tests/blueskyapi/client_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from blueskyapi import Client


def test_init_defaults():
client = Client()
assert client.base_url == "https://api.blueskyapi.io"
assert client.api_key == None
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import pytest


pytest_plugins = [
]

0 comments on commit 22f9ebd

Please sign in to comment.