Skip to content

Commit

Permalink
Added basic unittest.
Browse files Browse the repository at this point in the history
  • Loading branch information
DiddiZ committed Dec 4, 2021
1 parent f4bae81 commit b3b0ef7
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 8 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Tests

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

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Install pipenv
run: pip install pipenv
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
cache: "pipenv"
- name: Install dependencies
run: |
pipenv install --deploy --python ${{ matrix.python-version }}
- name: Test with pytest
run: |
pipenv run python -m unittest discover -v -s "./tests" -p "*_test.py"
14 changes: 8 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"editor.formatOnSave": true,
"python.formatting.provider": "yapf",
}
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"editor.formatOnSave": true,
"python.formatting.provider": "yapf",
"python.testing.unittestArgs": ["-v", "-s", "./tests", "-p", "*_test.py"],
"python.testing.unittestEnabled": true
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Tests](https://github.com/DiddiZ/donk.ai/actions/workflows/python-package.yml/badge.svg)](https://github.com/DiddiZ/mtg-proxies/actions/workflows/python-package.yml)

# MtG-Proxies

Create a high quality printable PDF from your decklist or a list of cards you want to proxy.
Expand Down
4 changes: 2 additions & 2 deletions examples/decklist.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Decklist
1 Alela, Artful Provocateur (ELD) 324
1 Korvold, Fae-Cursed King (ELD) 329
1 Liliana, Dreadhorde General (WAR) 97
1 Korvold, Fae-Cursed King (ELD) 329
1 Liliana, Dreadhorde General (WAR) 97
1 Murderous Rider // Swift End (ELD) 287
1 Growing Rites of Itlimoc // Itlimoc, Cradle of the Sun (XLN) 191

Expand Down
19 changes: 19 additions & 0 deletions tests/decklist_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import unittest


class Test_Decklist(unittest.TestCase):
def test_parsing(self):
from mtgproxies.decklists import parse_decklist

decklist, ok, warnings = parse_decklist("examples/decklist.txt")

self.assertTrue(ok)
self.assertEqual(len(warnings), 0)

with open("examples/decklist.txt", 'r', encoding="utf-8") as f:
# Ignore differences in linebreaks
self.assertEqual(
(format(decklist, "arena") + os.linesep).replace("\r\n", "\n"),
f.read().replace("\r\n", "\n"),
)

0 comments on commit b3b0ef7

Please sign in to comment.