-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from hardcoretech/feat/add_git_awareness
feature(mode): Add git awareness modes
- Loading branch information
Showing
4 changed files
with
195 additions
and
8 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,25 @@ | ||
name: Run Unit Test | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.6.8" | ||
- name: Install dependencies | ||
run: | | ||
pip install pip --upgrade | ||
pip install pytest | ||
- name: Test with pytest | ||
run: | | ||
PYTHONPATH=src pytest --log-level=debug --junitxml=junit_report.xml . | ||
- name: Publish Unit Test Results | ||
uses: EnricoMi/publish-unit-test-result-action/composite@v1 | ||
if: always() | ||
with: | ||
files: junit_report.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
Empty file.
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,69 @@ | ||
import os | ||
import tempfile | ||
|
||
import pytest | ||
|
||
from missing import Missing, Mode | ||
|
||
|
||
@pytest.fixture | ||
def temp_git_folder(): | ||
# Create a temp git folder so we could conduct the integration test | ||
|
||
with tempfile.TemporaryDirectory() as tmp_dir: | ||
os.chdir(tmp_dir) | ||
with open('.gitignore', 'w+') as fout: | ||
fout.write('test_ignore.py') | ||
|
||
os.mkdir('tests') | ||
os.mkdir(os.path.join('tests', 'ignored')) | ||
with open(os.path.join('tests', 'ignored', 'test_ignore.py'), 'w+'): | ||
pass | ||
|
||
os.mkdir(os.path.join('tests', 'untracked')) | ||
with open(os.path.join('tests', 'untracked', 'test_untracked.py'), 'w+'): | ||
pass | ||
|
||
os.mkdir(os.path.join('tests', 'staged')) | ||
with open(os.path.join('tests', 'staged', 'test_staged.py'), 'w+'): | ||
pass | ||
|
||
os.mkdir('data') | ||
with open(os.path.join('data', 'user.xml'), 'w+') as fount: | ||
pass | ||
|
||
os.system('git init') | ||
os.system('git add %s' % os.path.join('tests', 'staged')) | ||
yield | ||
|
||
|
||
class TestMissing: | ||
def test__default_mode(self, temp_git_folder): | ||
assert 1 == Missing(mode='all', exclude=[]).run() | ||
assert not os.path.exists('data/__init__.py') | ||
assert os.path.isfile('tests/ignored/__init__.py') | ||
assert os.path.isfile('tests/untracked/__init__.py') | ||
assert os.path.isfile('tests/staged/__init__.py') | ||
assert os.path.isfile('tests/__init__.py') | ||
assert 0 == Missing(mode=Mode.ALL, exclude=[]).run() | ||
|
||
def test__obey_gitignore(self, temp_git_folder): | ||
assert 1 == Missing(mode='obey_gitignore', exclude=[]).run() | ||
assert not os.path.exists('data/__init__.py') | ||
assert not os.path.exists('tests/ignored/__init__.py') | ||
assert os.path.isfile('tests/untracked/__init__.py') | ||
assert os.path.isfile('tests/staged/__init__.py') | ||
assert os.path.isfile('tests/__init__.py') | ||
assert 0 == Missing(mode=Mode.OBEY_GITIGNORE, exclude=[]).run() | ||
|
||
def test__staged_only(self, temp_git_folder): | ||
assert 1 == Missing(mode='staged_only', exclude=[]).run() | ||
assert not os.path.exists('data/__init__.py') | ||
assert not os.path.exists('tests/ignored/__init__.py') | ||
assert not os.path.exists('tests/untracked/__init__.py') | ||
assert os.path.isfile('tests/staged/__init__.py') | ||
assert os.path.isfile('tests/__init__.py') | ||
assert 0 == Missing(mode=Mode.STAGED_ONLY, exclude=[]).run() | ||
|
||
def test__exclude(self, temp_git_folder): | ||
assert 0 == Missing(mode=Mode.ALL, exclude=['tests']).run() |