Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added base OS info to metadata endpoint #4097

Merged
merged 3 commits into from
Feb 13, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions securedrop/tests/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from db import db
from models import Source, Reply
from source_app import main as source_app_main
from source_app import api as source_app_api
from utils.db_helper import new_codename
from utils.instrument import InstrumentedApp

Expand Down Expand Up @@ -515,14 +516,17 @@ def test_why_journalist_key(source_app):
assert "Why download the journalist's public key?" in text


def test_metadata_route(source_app):
with source_app.test_client() as app:
resp = app.get(url_for('api.metadata'))
assert resp.status_code == 200
assert resp.headers.get('Content-Type') == 'application/json'
assert json.loads(resp.data.decode('utf-8')).get('sd_version') \
== version.__version__
assert resp.get('server_os') == 16.04
def test_metadata_route(source_app, mocker):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nightwarrior-xxx Why do we have this mocker here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's from pytest-mock

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah this is doubly mocked...

with patch.object(source_app_api.platform, "linux_distribution") as mocked_platform:
mocked_platform.return_value = ("Ubuntu", "16.04", "xenial")
with source_app.test_client() as app:
resp = app.get(url_for('api.metadata'))
assert resp.status_code == 200
assert resp.headers.get('Content-Type') == 'application/json'
assert json.loads(resp.data.decode('utf-8')).get('sd_version') \
== version.__version__
assert json.loads(resp.data.decode('utf-8')).get('server_os') \
== '16.04'


def test_login_with_overly_long_codename(source_app):
Expand Down