Esempio n. 1
0
def test_merge_new_mod_draft(db_session, client, sample_users, sample_mods):
    draft = DraftMod(name="New Mod",
                     desc="This is a draft of a new mod",
                     authors=[ModAuthor(name="testing")],
                     user=sample_users['admin'],
                     mod_vsns=[
                         DraftModVersion(
                             name='6.9',
                             desc='Testing',
                             game_vsns=[GameVersion(name='1.7.10')])
                     ])
    db_session.add(draft)
    db_session.commit()

    login_as(client, sample_users['admin'])
    rv = client.post(url_for('edit.draft_diff', id=draft.id),
                     follow_redirects=True,
                     data=dict(slug='added'))
    print(rv.data)

    mod = Mod.query.filter_by(slug='added').first()
    assert mod.name == draft.name
    assert mod.desc == draft.desc
    assert mod.authors == draft.authors
    assert mod.mod_vsns[0].name == draft.mod_vsns[0].name
    assert mod.mod_vsns[0].desc == draft.mod_vsns[0].desc
    assert mod.mod_vsns[0].game_vsns == draft.mod_vsns[0].game_vsns
Esempio n. 2
0
def test_mk_draft(client, sample_users, sample_mods):
    mod = sample_mods[0]
    login_as(client, sample_users['admin'])
    rv = client.post(url_for('edit.new_draft', slug=mod.slug), follow_redirects=True)
    assert mod.name.encode('utf-8') in rv.data

    # Check the DB
    draft = DraftMod.query.filter_by(name=mod.name).first()
    assert draft != None, "Draft not found in DB"
Esempio n. 3
0
def test_empty_draft(db_session, client, sample_users, sample_mods):
    """Ensures that drafts with no changes can't be merged."""
    mod = sample_mods[0]
    draft = mk_draft(db_session, mod, sample_users['admin'])

    login_as(client, sample_users['admin'])
    rv = client.post(url_for('edit.draft_diff', id=draft.id),
                     follow_redirects=True)
    assert b'no changes' in rv.data
Esempio n. 4
0
def test_edit_mod(db_session, client, sample_users, sample_mods):
    mod = mk_draft(db_session, sample_mods[0])
    data = dict(
        name='Edited', desc='This is a test',
    )
    login_as(client, sample_users['admin'])
    rv = client.post(url_for('edit.edit_mod', id=mod.id), data=data, follow_redirects=True)
    assert data['name'].encode('utf-8') in rv.data

    # Check the DB
    mod = DraftMod.query.filter_by(id=mod.id).first()
    assert mod != None, "Edited draft not found in DB"
    assert mod.name == data['name']
    assert mod.desc == data['desc']
Esempio n. 5
0
def test_new_vsn(db_session, client, sample_users, sample_mods):
    mod = mk_draft(db_session, sample_mods[0])
    data = dict(
        name='New Version', desc='This is a test',
    )
    login_as(client, sample_users['admin'])
    rv = client.post(url_for('edit.new_mod_version', id=mod.id), data=data,
            follow_redirects=True)
    assert data['name'].encode('utf-8') in rv.data

    # Check the DB
    vsn = DraftModVersion.query.filter_by(name=data['name']).first()
    assert vsn != None, "New version not found in DB"
    assert vsn.name == data['name']
    assert vsn.desc == data['desc']
Esempio n. 6
0
def test_new_mod(client, sample_users, sample_mods):
    data = dict(
        name='New Test Mod', website='', authors=['1'],
        desc='This is a test',
    )
    login_as(client, sample_users['admin'])
    rv = client.post(url_for('edit.new_mod'), data=data, follow_redirects=True)
    assert data['name'].encode('utf-8') in rv.data

    # Check the DB
    mod = DraftMod.query.filter_by(name=data['name']).first()
    assert mod != None, "Added mod not found in DB"
    assert mod.name == data['name']
    assert mod.website == data['website']
    assert mod.desc == data['desc']
Esempio n. 7
0
def test_merge_new_version_draft(db_session, client, sample_users,
                                 sample_mods):
    mod = sample_mods[0]

    oldauthors = mod.authors

    draft = mk_draft(db_session, mod, sample_users['admin'])
    draft.mod_vsns.append(DraftModVersion(
        name='6.9',
        desc='Testing',
    ))
    db_session.commit()

    login_as(client, sample_users['admin'])
    rv = client.post(url_for('edit.draft_diff', id=draft.id),
                     follow_redirects=True)

    mvsn = mod.find_same_child(draft.mod_vsns[0])
    assert mvsn.name == draft.mod_vsns[0].name
    assert mvsn.desc == draft.mod_vsns[0].desc
Esempio n. 8
0
def test_merge_draft(db_session, client, sample_users, sample_mods):
    mod = sample_mods[0]

    oldauthors = mod.authors

    draft = mk_draft(db_session, mod, sample_users['admin'])
    draft.name = "Changed 1"
    draft.desc = "Changed 2"
    draft.mod_vsns[0].desc = "Changed 3"
    db_session.commit()

    login_as(client, sample_users['admin'])
    rv = client.post(url_for('edit.draft_diff', id=draft.id),
                     follow_redirects=True)

    assert mod.name == draft.name
    assert mod.desc == draft.desc
    assert mod.authors == oldauthors

    mvsn = mod.find_same_child(draft.mod_vsns[0])
    assert mvsn.desc == draft.mod_vsns[0].desc
Esempio n. 9
0
def test_mod_revision(client, sample_users, sample_mods):
    sm = sample_mods[0]
    login_as(client, sample_users['admin'])
    rv = client.get('/mods/{}/history/{}'.format(sm.slug, 0))
    assert b'revision 0' in rv.data
Esempio n. 10
0
def test_reset_pass(client, sample_users):
    login_as(client, sample_users['admin'])