@pytest.mark.parametrize('test_name,state,legal_type,username,roles,expected', [('staff_active_cp', Business.State.ACTIVE, 'CP', 'staff', [STAFF_ROLE], ['annualReport', 'changeOfAddress', 'changeOfDirectors', 'correction', 'courtOrder', 'dissolution', 'incorporationApplication', 'specialResolution', 'registrarsNotation', 'registrarsOrder']), ('staff_active_bc', Business.State.ACTIVE, 'BC', 'staff', [STAFF_ROLE], ['alteration', 'courtOrder', 'dissolution', 'incorporationApplication', 'transition', 'registrarsNotation', 'registrarsOrder']), ('staff_active_ben', Business.State.ACTIVE, 'BEN', 'staff', [STAFF_ROLE], ['alteration', 'annualReport', 'changeOfAddress', 'changeOfDirectors', 'conversion', 'correction', 'courtOrder', 'dissolution', 'incorporationApplication', 'transition', 'registrarsNotation', 'registrarsOrder']), ('staff_active_cc', Business.State.ACTIVE, 'CC', 'staff', [STAFF_ROLE], ['courtOrder', 'dissolution', 'registrarsNotation', 'registrarsOrder']), ('staff_active_ulc', Business.State.ACTIVE, 'ULC', 'staff', [STAFF_ROLE], ['alteration', 'courtOrder', 'dissolution', 'registrarsNotation', 'registrarsOrder']), ('staff_active_llc', Business.State.ACTIVE, 'LLC', 'staff', [STAFF_ROLE], ['courtOrder', 'dissolution', 'registrarsNotation', 'registrarsOrder']), ('staff_active_sp', Business.State.ACTIVE, 'SP', 'staff', [STAFF_ROLE], ['changeOfRegistration', 'conversion', 'dissolution', 'registration']), ('staff_active_gp', Business.State.ACTIVE, 'GP', 'staff', [STAFF_ROLE], ['changeOfRegistration', 'conversion', 'dissolution', 'registration']), ('user_active_cp', Business.State.ACTIVE, 'CP', 'user', [BASIC_USER], ['annualReport', 'changeOfAddress', 'changeOfDirectors', 'dissolution', 'incorporationApplication', 'specialResolution']), ('user_active_bc', Business.State.ACTIVE, 'BC', 'user', [BASIC_USER], ['alteration', 'dissolution', 'incorporationApplication', 'transition']), ('user_active_ben', Business.State.ACTIVE, 'BEN', 'user', [BASIC_USER], ['alteration', 'annualReport', 'changeOfAddress', 'changeOfDirectors', 'dissolution', 'incorporationApplication', 'transition']), ('user_active_cc', Business.State.ACTIVE, 'CC', 'user', [BASIC_USER], ['dissolution']), ('user_active_ulc', Business.State.ACTIVE, 'ULC', 'user', [BASIC_USER], ['alteration', 'dissolution']), ('user_active_llc', Business.State.ACTIVE, 'LLC', 'user', [BASIC_USER], ['dissolution']), ('user_active_sp', Business.State.ACTIVE, 'SP', 'user', [BASIC_USER], ['changeOfRegistration', 'dissolution', 'registration']), ('user_active_gp', Business.State.ACTIVE, 'GP', 'user', [BASIC_USER], ['changeOfRegistration', 'dissolution', 'registration']), ('staff_historical_cp', Business.State.HISTORICAL, 'CP', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration']}]), ('staff_historical_bc', Business.State.HISTORICAL, 'BC', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('staff_historical_ben', Business.State.HISTORICAL, 'BEN', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('staff_historical_cc', Business.State.HISTORICAL, 'CC', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('staff_historical_ulc', Business.State.HISTORICAL, 'ULC', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('staff_historical_llc', Business.State.HISTORICAL, 'LLC', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('user_historical_llc', Business.State.HISTORICAL, 'LLC', 'user', [BASIC_USER], [])])
def test_get_allowed(monkeypatch, app, jwt, test_name, state, legal_type, username, roles, expected):
    'Assert that get allowed returns valid filings.'
    token = helper_create_jwt(jwt, roles=roles, username=username)
    headers = {'Authorization': ('Bearer ' + token)}

    def mock_auth(one, two):
        return headers[one]
    with app.test_request_context():
        monkeypatch.setattr('flask.request.headers.get', mock_auth)
        filing_types = get_allowed(state, legal_type, jwt)
        assert (filing_types == expected)
Assert that get allowed returns valid filings.
@pytest.mark.parametrize('test_name,state,legal_type,username,roles,expected', [('staff_active_cp', Business.State.ACTIVE, 'CP', 'staff', [STAFF_ROLE], ['annualReport', 'changeOfAddress', 'changeOfDirectors', 'correction', 'courtOrder', 'dissolution', 'incorporationApplication', 'specialResolution', 'registrarsNotation', 'registrarsOrder']), ('staff_active_bc', Business.State.ACTIVE, 'BC', 'staff', [STAFF_ROLE], ['alteration', 'courtOrder', 'dissolution', 'incorporationApplication', 'transition', 'registrarsNotation', 'registrarsOrder']), ('staff_active_ben', Business.State.ACTIVE, 'BEN', 'staff', [STAFF_ROLE], ['alteration', 'annualReport', 'changeOfAddress', 'changeOfDirectors', 'conversion', 'correction', 'courtOrder', 'dissolution', 'incorporationApplication', 'transition', 'registrarsNotation', 'registrarsOrder']), ('staff_active_cc', Business.State.ACTIVE, 'CC', 'staff', [STAFF_ROLE], ['courtOrder', 'dissolution', 'registrarsNotation', 'registrarsOrder']), ('staff_active_ulc', Business.State.ACTIVE, 'ULC', 'staff', [STAFF_ROLE], ['alteration', 'courtOrder', 'dissolution', 'registrarsNotation', 'registrarsOrder']), ('staff_active_llc', Business.State.ACTIVE, 'LLC', 'staff', [STAFF_ROLE], ['courtOrder', 'dissolution', 'registrarsNotation', 'registrarsOrder']), ('staff_active_sp', Business.State.ACTIVE, 'SP', 'staff', [STAFF_ROLE], ['changeOfRegistration', 'conversion', 'dissolution', 'registration']), ('staff_active_gp', Business.State.ACTIVE, 'GP', 'staff', [STAFF_ROLE], ['changeOfRegistration', 'conversion', 'dissolution', 'registration']), ('user_active_cp', Business.State.ACTIVE, 'CP', 'user', [BASIC_USER], ['annualReport', 'changeOfAddress', 'changeOfDirectors', 'dissolution', 'incorporationApplication', 'specialResolution']), ('user_active_bc', Business.State.ACTIVE, 'BC', 'user', [BASIC_USER], ['alteration', 'dissolution', 'incorporationApplication', 'transition']), ('user_active_ben', Business.State.ACTIVE, 'BEN', 'user', [BASIC_USER], ['alteration', 'annualReport', 'changeOfAddress', 'changeOfDirectors', 'dissolution', 'incorporationApplication', 'transition']), ('user_active_cc', Business.State.ACTIVE, 'CC', 'user', [BASIC_USER], ['dissolution']), ('user_active_ulc', Business.State.ACTIVE, 'ULC', 'user', [BASIC_USER], ['alteration', 'dissolution']), ('user_active_llc', Business.State.ACTIVE, 'LLC', 'user', [BASIC_USER], ['dissolution']), ('user_active_sp', Business.State.ACTIVE, 'SP', 'user', [BASIC_USER], ['changeOfRegistration', 'dissolution', 'registration']), ('user_active_gp', Business.State.ACTIVE, 'GP', 'user', [BASIC_USER], ['changeOfRegistration', 'dissolution', 'registration']), ('staff_historical_cp', Business.State.HISTORICAL, 'CP', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration']}]), ('staff_historical_bc', Business.State.HISTORICAL, 'BC', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('staff_historical_ben', Business.State.HISTORICAL, 'BEN', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('staff_historical_cc', Business.State.HISTORICAL, 'CC', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('staff_historical_ulc', Business.State.HISTORICAL, 'ULC', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('staff_historical_llc', Business.State.HISTORICAL, 'LLC', 'staff', [STAFF_ROLE], ['courtOrder', 'registrarsNotation', 'registrarsOrder', {'restoration': ['fullRestoration', 'limitedRestoration']}]), ('user_historical_llc', Business.State.HISTORICAL, 'LLC', 'user', [BASIC_USER], [])])
def test_get_allowed(monkeypatch, app, jwt, test_name, state, legal_type, username, roles, expected):
    
    token = helper_create_jwt(jwt, roles=roles, username=username)
    headers = {'Authorization': ('Bearer ' + token)}

    def mock_auth(one, two):
        return headers[one]
    with app.test_request_context():
        monkeypatch.setattr('flask.request.headers.get', mock_auth)
        filing_types = get_allowed(state, legal_type, jwt)
        assert (filing_types == expected)