Esempio n. 1
0
def test_updateStatusInvalid(client):

    createFakeUser(fakePriviledgedEmail)
    loginFakeUser(client, fakePriviledgedEmail)
    createFakeApp()

    client.get('/update-status/' + fakeApp['ID'] + '/Invalid Status',
               follow_redirects=True)
    # print(request.path, request.args)
    app = appDict(fakeApp['ID'])
    assert (app['Status'] == fakeApp['Status'])

    deleteFakeUser(fakePriviledgedEmail)
    deleteFakeApp()
Esempio n. 2
0
def test_add_to_appQueue(client):
    createFakeUser()
    loginFakeUser(client, fakeEmail)

    oldApps = glob.glob(os.path.join(APPLICATIONS_DIR, '*'))
    client.post('/add-to-queue', data=fakeApp, follow_redirects=True)
    # print(request.path, request.args)
    allApps = glob.glob(os.path.join(APPLICATIONS_DIR, '*'))
    newApps = list(set(allApps) - set(oldApps))
    newAppID = os.path.split(newApps[0])[1]
    app = appDict(newAppID)
    assert (app['placeholder'] == 'data')
    shutil.rmtree(newApps[0])
    deleteFakeUser()
Esempio n. 3
0
def test_successValidTokenSelfInstall(client):

    createFakeUser()
    fakeApp['Installation Type'] = 'Self-install'
    createFakeApp()
    loginFakeUser(client, fakeEmail)

    token = hashPassword(fakeApp['ID'], COOKIE_KEY)
    route = '/success/' + fakeApp['ID'] + '/' + token
    checkResponseStatusOnGet(client, route, 200)

    app = appDict(fakeApp['ID'])
    assert (app['Status'] == 'Application Submitted')

    deleteFakeUser()
    deleteFakeApp()
Esempio n. 4
0
def test_delegateValidToken(client):

    createFakeUser()
    loginFakeUser(client, fakeEmail)

    fakeApp['Status'] = 'Delegation Required'
    createFakeApp()

    token = hashPassword('delegation', fakeApp['ID'])
    checkResponseStatusOnGet(client,
                             '/delegate/' + fakeApp['ID'] + '/' + token, 200)

    app = appDict(fakeApp['ID'])
    assert (app['Status'] == 'Application Submitted')

    deleteFakeUser()
    deleteFakeApp()
Esempio n. 5
0
def test_successValidToken(client):

    createFakeUser()
    fakeApp['Installation Type'] = 'Contractor only'
    fakeApp['Email (Contractor)'] = '*****@*****.**'
    fakeApp['Address (Service)'] = 'address'
    createFakeApp()
    loginFakeUser(client, fakeEmail)

    token = hashPassword(fakeApp['ID'], COOKIE_KEY)
    route = '/success/' + fakeApp['ID'] + '/' + token
    checkResponseStatusOnGet(client, route, 200)

    app = appDict(fakeApp['ID'])
    assert (app['Status'] == 'Delegation Required')

    deleteFakeUser()
    deleteFakeApp()
Esempio n. 6
0
def test_editLoggedIn(client):

    createFakeUser()
    loginFakeUser(client, fakeEmail)
    createFakeApp()

    client.post('/updateApp/' + fakeApp['ID'],
                data=editedFakeApp,
                follow_redirects=True)
    # print(request.path, request.args)

    app, edits = appDict(fakeApp['ID']), appEditsDict(fakeApp['ID'])
    assert ((edits['placeholder'], app['Previous Status'],
             app['Status']) == ('newData', fakeApp['Status'],
                                'Engineering Review'))

    deleteFakeApp()
    deleteFakeUser()
Esempio n. 7
0
def test_save_notesEmpty(client):

    createFakeUser()
    fakeApp['Notes'] = 'oldNote'
    createFakeApp()
    loginFakeUser(client, fakeEmail)
    data = {'notesText': ''}
    response = client.post('/save-notes/' + fakeApp['ID'],
                           data=data,
                           follow_redirects=True)
    # print(request.path, request.args)
    condition0 = response.status_code == 200

    app = appDict(fakeApp['ID'])
    condition1 = app['Notes'] == fakeApp['Notes']

    assert ((condition0, condition1) == (True, True))
    deleteFakeApp()
    deleteFakeUser()
Esempio n. 8
0
def test_reviewEditsReject(client):

    createFakeUser(fakePriviledgedEmail)
    loginFakeUser(client, fakePriviledgedEmail)
    createFakeApp()

    client.post('/updateApp/' + fakeApp['ID'],
                data=editedFakeApp,
                follow_redirects=True)
    client.get('/reviewEdits/' + fakeApp['ID'] + '/reject',
               follow_redirects=True)
    # print(request.path, request.args)

    app = appDict(fakeApp['ID'])
    assert ((app['placeholder'], app['Status'],
             app.get('Previous Status')) == (fakeApp['placeholder'],
                                             fakeApp['Status'], None))

    deleteFakeUser(fakePriviledgedEmail)
    deleteFakeApp()
Esempio n. 9
0
def test_save_notes(client):

    createFakeUser()
    fakeApp['Notes'] = 'oldNote'
    createFakeApp()
    loginFakeUser(client, fakeEmail)
    data = {'notesText': 'newNote'}
    response = client.post('/save-notes/' + fakeApp['ID'],
                           data=data,
                           follow_redirects=True)
    # print(request.path, request.args)
    condition0 = response.status_code == 200

    app = appDict(fakeApp['ID'])
    notes = app['Notes'].split('\n\n')
    oldNote = notes[0].split(': \n')
    newNote = notes[-1].split(': \n')
    condition1 = oldNote[-1] == 'oldNote'
    condition2 = newNote[-1] == 'newNote'

    assert ((condition0, condition1, condition2) == (True, True, True))
    deleteFakeApp()
    deleteFakeUser()