Skip to content

Commit

Permalink
Remove GitHub version call
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiefdhurst committed Jul 30, 2023
1 parent f627041 commit 1bded30
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 40 deletions.
7 changes: 0 additions & 7 deletions blog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ def create_app(test_config=None):
except OSError:
pass

github = requests.get('https://api.github.com/repos/jamiefdhurst/blog/releases',
auth=(app.config['GITHUB_USERNAME'], app.config['GITHUB_TOKEN']))
if github.status_code == 200:
response = github.json()
if len(response):
app.config.update(VERSION=response[0]['name'])

@app.before_request
def load_version():
# pylint: disable=assigning-non-slot
Expand Down
4 changes: 1 addition & 3 deletions blog/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

SECRET_KEY = environ.get('SECRET_KEY', default='dev')
ARTICLES_DIR = environ.get('ARTICLES_DIR', default='articles/')
GITHUB_USERNAME = environ.get('GITHUB_USERNAME', default='')
GITHUB_TOKEN = environ.get('GITHUB_TOKEN', default='')
VERSION = 'DEVELOPMENT'
VERSION = 'v0.18'
18 changes: 0 additions & 18 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,10 @@
from blog import create_app


@pytest.fixture
def mock_github_request_empty_response(requests_mock):
requests_mock.get(
'https://api.github.com/repos/jamiefdhurst/blog/releases',
json='',
)


@pytest.fixture
def mock_github_request(requests_mock):
requests_mock.get(
'https://api.github.com/repos/jamiefdhurst/blog/releases',
json=[{'name': 'v1.0-TEST'}],
)


@pytest.fixture
def app():
app = create_app({
'ARTICLES_DIR': 'tests/articles/',
'GITHUB_USERNAME': 'jamiefdhurst',
'GITHUB_TOKEN': 'example',
'TESTING': True,
'VERSION': 'DEVELOPMENT',
})
Expand Down
12 changes: 0 additions & 12 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,9 @@ def test_config():
assert not create_app().testing
app = create_app({
'ARTICLES_DIR': 'tests/articles/',
'GITHUB_USERNAME': 'jamiefdhurst',
'GITHUB_TOKEN': 'example',
'TESTING': True})
assert app.testing
assert app.config['ARTICLES_DIR'] == 'tests/articles/'
assert app.config['GITHUB_USERNAME'] == 'jamiefdhurst'
assert app.config['GITHUB_TOKEN'] == 'example'

def test_github_empty_response(mock_github_request_empty_response, client):
response = client.get('/')
assert b'System DEVELOPMENT' in response.data

def test_github_successful_response(mock_github_request, client):
response = client.get('/')
assert b'System v1.0-TEST' in response.data

def test_404(client):
response = client.get('/not-found-path')
Expand Down

0 comments on commit 1bded30

Please sign in to comment.