Skip to content

Commit

Permalink
first commit with some playaround code
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdelrue committed Jul 19, 2020
0 parents commit af8301c
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pytest_cache
.idea
__pycache__
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This project is just a personal playground for getting to know GH actions and how to set up a CI/CD pipeline with it for a generic Python Project
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage
pytest
pytest-cov
requests
Empty file added src/redshirt/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions src/redshirt/something.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import requests as req


def func_a(arg):
return arg + 1


def func_b(name: str) -> str:
return name


def get_uuid():
resp = req.get('http://httpbin.org/uuid')
return resp.json()['uuid']


def main():
print(func_a(0))
print(func_b('narcissus'))
print(get_uuid())


if __name__ == '__main__':
main()
5 changes: 5 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os.path
import sys

main_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'src'))
sys.path.append(main_path)
23 changes: 23 additions & 0 deletions tests/test_something.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest
import requests

from redshirt import something


def test_func_a():
assert 1 == something.func_a(0)


class MockResponse:
@staticmethod
def json():
return {'uuid': 'stub_uuid'}


def test_get_uuid(monkeypatch):
def mock_get(*args, **kwargs):
return MockResponse()

monkeypatch.setattr(requests, 'get', mock_get)

assert 'stub_uuid' == something.get_uuid()

0 comments on commit af8301c

Please sign in to comment.