Fix some issues from a tricky merge
This commit is contained in:
@@ -5,7 +5,6 @@ import alembic.command
|
||||
|
||||
from atst.app import make_app, make_config
|
||||
from atst.database import db as _db
|
||||
from .mocks import MOCK_USER
|
||||
import tests.factories as factories
|
||||
|
||||
|
||||
@@ -75,7 +74,6 @@ class DummyForm(dict):
|
||||
|
||||
|
||||
class DummyField(object):
|
||||
|
||||
def __init__(self, data=None, errors=(), raw_data=None):
|
||||
self.data = data
|
||||
self.errors = list(errors)
|
||||
@@ -93,9 +91,11 @@ def dummy_field():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user_session(monkeypatch):
|
||||
|
||||
def set_user_session(user=MOCK_USER):
|
||||
monkeypatch.setattr("atst.domain.auth.get_current_user", lambda *args: user)
|
||||
def user_session(monkeypatch, session):
|
||||
def set_user_session(user=None):
|
||||
monkeypatch.setattr(
|
||||
"atst.domain.auth.get_current_user",
|
||||
lambda *args: user or factories.UserFactory.build(),
|
||||
)
|
||||
|
||||
return set_user_session
|
||||
|
@@ -53,6 +53,6 @@ def test_dont_auto_approve_if_no_dollar_value_specified(new_request):
|
||||
def test_exists(session):
|
||||
user_allowed = UserFactory.create()
|
||||
user_denied = UserFactory.create()
|
||||
request = RequestFactory.create(creator=user_allowed.id)
|
||||
assert Requests.exists(request.id, user_allowed.id)
|
||||
assert not Requests.exists(request.id, user_denied.id)
|
||||
request = RequestFactory.create(creator=user_allowed)
|
||||
assert Requests.exists(request.id, user_allowed)
|
||||
assert not Requests.exists(request.id, user_denied)
|
||||
|
@@ -20,7 +20,7 @@ class RoleFactory(factory.alchemy.SQLAlchemyModelFactory):
|
||||
|
||||
permissions = []
|
||||
|
||||
|
||||
|
||||
class UserFactory(factory.alchemy.SQLAlchemyModelFactory):
|
||||
class Meta:
|
||||
model = User
|
||||
@@ -47,7 +47,7 @@ class RequestFactory(factory.alchemy.SQLAlchemyModelFactory):
|
||||
|
||||
id = factory.Sequence(lambda x: uuid4())
|
||||
status_events = factory.RelatedFactory(
|
||||
RequestStatusFactory, "request", new_status=RequestStatus.STARTED
|
||||
RequestStatusEventFactory, "request", new_status=RequestStatus.STARTED
|
||||
)
|
||||
creator = factory.SubFactory(UserFactory)
|
||||
body = factory.LazyAttribute(lambda r: RequestFactory.build_request_body(r.creator))
|
||||
|
@@ -33,7 +33,7 @@ def test_submit_valid_request_form(monkeypatch, client, user_session):
|
||||
def test_owner_can_view_request(client, user_session):
|
||||
user = UserFactory.create()
|
||||
user_session(user)
|
||||
request = RequestFactory.create(creator=user.id)
|
||||
request = RequestFactory.create(creator=user)
|
||||
|
||||
response = client.get("/requests/new/1/{}".format(request.id), follow_redirects=True)
|
||||
|
||||
|
Reference in New Issue
Block a user