コード例 #1
0
ファイル: logic_test.py プロジェクト: njl/progcom
def test_voting_basics():
    l.add_proposal(data)
    standards = [l.add_standard("About Pythong"), l.add_standard("Awesome")]
    uid = l.add_user('*****@*****.**', 'Bob', 'bob')
    assert not l.get_votes(123)
    assert not l.vote(uid, 123, {k:3 for k in standards})
    assert not l.get_votes(123)

    assert l.get_proposal(123).vote_count == 0

    l.approve_user(uid)

    assert not l.vote(uid, 123, {})
    assert not l.get_votes(123)

    assert l.vote(uid, 123, {k:2 for k in standards})
    assert l.get_votes(123)[0].scores == {k:2 for k in standards}
    assert l.get_proposal(123).vote_count == 1

    assert not l.vote(uid, 123, {k:7 for k in standards})
    assert l.get_votes(123)[0].scores == {k:2 for k in standards}

    assert l.vote(uid, 123, {k:0 for k in standards})
    assert len(l.get_votes(123)) == 1
    assert l.get_votes(123)[0].scores == {k:0 for k in standards}
    assert l.get_proposal(123).vote_count == 1
コード例 #2
0
ファイル: logic_test.py プロジェクト: themson/progcom
def test_voting_basics():
    l.add_proposal(data)
    standards = [l.add_standard("About Pythong"), l.add_standard("Awesome")]
    uid = l.add_user('*****@*****.**', 'Bob', 'bob')
    assert not l.get_votes(123)
    assert not l.vote(uid, 123, {k: 3 for k in standards})
    assert not l.get_votes(123)

    assert l.get_proposal(123).vote_count == 0

    l.approve_user(uid)

    assert not l.vote(uid, 123, {})
    assert not l.get_votes(123)

    assert l.vote(uid, 123, {k: 2 for k in standards})
    assert l.get_votes(123)[0].scores == {k: 2 for k in standards}
    assert l.get_proposal(123).vote_count == 1

    assert not l.vote(uid, 123, {k: 7 for k in standards})
    assert l.get_votes(123)[0].scores == {k: 2 for k in standards}

    assert l.vote(uid, 123, {k: 0 for k in standards})
    assert len(l.get_votes(123)) == 1
    assert l.get_votes(123)[0].scores == {k: 0 for k in standards}
    assert l.get_proposal(123).vote_count == 1
コード例 #3
0
def main():
    lt.transact()
    emails = ['user{}@example.com'.format(n) for n in range(50)]
    for e in emails[:25]:
        uid = l.add_user(e, '{} Person'.format(e.split('@')[0]), 'abc123')
        l.approve_user(uid)


    for n in range(6):
        l.add_standard(words(3, 10)[:50])

    user_ids = [x.id for x in l.list_users()]
    standards = [x.id for x in l.get_standards()]
    
    proposal_ids = []
    for n in range(200):
        prop_id = n*2
        data = {'id': prop_id, 'authors': [{'email': random.choice(emails),
                                        'name': 'Speaker Name Here'}],
                'title': words(3,8).title(),
                'category': words(1,2),
                'duration': '30 minutes',
                'description': ipsum(4),
                'audience': ipsum(1),
                'audience_level': 'Novice',
                'notes': ipsum(2),
                'objective': ipsum(1),
                'recording_release': bool(random.random() > 0.05),
                'abstract': ipsum(1),
                'outline': ipsum(5)+"\n[test](http://www.google.com/)\n",
                'additional_notes': ipsum(1),
                'additional_requirements': ipsum(1)}
        l.add_proposal(data)
        proposal_ids.append(prop_id)

        if random.randint(0, 3) == 0:
            for n in range(random.randint(1, 10)):
                l.add_to_discussion(random.choice(user_ids), prop_id, ipsum(1))

        if random.randint(0, 2) == 0:
            for n in range(random.randint(1, 5)):
                vote = {k:random.randint(0, 2) for k in standards}
                l.vote(random.choice(user_ids), prop_id, vote)

        if random.randint(0, 3) == 0:
            data['description'] = 'UPDATED ' + ipsum(4)
            l.add_proposal(data)


    random.shuffle(proposal_ids)

    proposal_ids = proposal_ids[:70]
    for n in range(0, len(proposal_ids), 5):
        l.create_group(words(2,4).title(),
                proposal_ids[n:n+5])
コード例 #4
0
ファイル: fill_db_with_fakes.py プロジェクト: themson/progcom
def main():
    lt.transact()
    emails = ["user{}@example.com".format(n) for n in range(50)]
    for e in emails[:25]:
        uid = l.add_user(e, "{} Person".format(e.split("@")[0]), "abc123")
        l.approve_user(uid)

    for n in range(6):
        l.add_standard(words(3, 10)[:50])

    user_ids = [x.id for x in l.list_users()]
    standards = [x.id for x in l.get_standards()]

    proposal_ids = []
    for n in range(200):
        prop_id = n * 2
        data = {
            "id": prop_id,
            "authors": [{"email": random.choice(emails), "name": "Speaker Name Here"}],
            "title": words(3, 8).title(),
            "category": words(1, 2),
            "duration": "30 minutes",
            "description": ipsum(4),
            "audience": ipsum(1),
            "audience_level": "Novice",
            "notes": ipsum(2),
            "objective": ipsum(1),
            "recording_release": bool(random.random() > 0.05),
            "abstract": ipsum(1),
            "outline": ipsum(5) + "\n[test](http://www.google.com/)\n",
            "additional_notes": ipsum(1),
            "additional_requirements": ipsum(1),
        }
        l.add_proposal(data)
        proposal_ids.append(prop_id)

        if random.randint(0, 3) == 0:
            for n in range(random.randint(1, 10)):
                l.add_to_discussion(random.choice(user_ids), prop_id, ipsum(1))

        if random.randint(0, 2) == 0:
            for n in range(random.randint(1, 5)):
                vote = {k: random.randint(0, 2) for k in standards}
                l.vote(random.choice(user_ids), prop_id, vote)

        if random.randint(0, 3) == 0:
            data["notes"] = "UPDATED" + ipsum(2)
            l.add_proposal(data)

    random.shuffle(proposal_ids)

    proposal_ids = proposal_ids[:70]
    for n in range(0, len(proposal_ids), 5):
        l.create_group(words(2, 4).title(), proposal_ids[n : n + 5])
コード例 #5
0
ファイル: logic_test.py プロジェクト: themson/progcom
def test_needs_votes():
    proposals = []
    users = {}
    standards = [l.add_standard("About Pythong"), l.add_standard("Awesome")]
    sample_vote = {k: 2 for k in standards}
    for n in range(1, 10):
        prop = data.copy()
        prop['id'] = n * 2
        prop['abstract'] = 'Proposal {}'.format(n)
        email = '{}@example.com'.format(n)
        uid = l.add_user(email, email, email)
        l.approve_user(uid)
        users[email] = uid
        prop['authors'] = [{'email': email, 'name': 'foo'}]
        l.add_proposal(prop)
        proposals.append(n * 2)

    non_author_email = '*****@*****.**'
    non_author_id = l.add_user(non_author_email, non_author_email,
                               non_author_email)
    l.approve_user(non_author_id)

    random.seed(0)
    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes(non_author_email, non_author_id))
    assert seen_ids == set(proposals)

    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes('*****@*****.**', users['*****@*****.**']))
    not_2_proposals = set(proposals)
    not_2_proposals.remove(4)
    assert seen_ids == not_2_proposals

    for n in range(1, 9):
        l.vote(users['*****@*****.**'], n * 2, sample_vote)

    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes(non_author_email, non_author_id))
    assert seen_ids == set([18])

    l.vote(users['*****@*****.**'], 18, sample_vote)

    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes(non_author_email, non_author_id))
    assert seen_ids == set(proposals)
コード例 #6
0
ファイル: logic_test.py プロジェクト: njl/progcom
def test_needs_votes():
    proposals = []
    users = {}
    standards = [l.add_standard("About Pythong"), l.add_standard("Awesome")]
    sample_vote = {k:2 for k in standards}
    for n in range(1,10):
        prop = data.copy()
        prop['id'] = n*2
        prop['abstract'] = 'Proposal {}'.format(n)
        email = '{}@example.com'.format(n)
        uid = l.add_user(email, email, email)
        l.approve_user(uid)
        users[email] = uid
        prop['authors'] = [{'email':email, 'name':'foo'}]
        l.add_proposal(prop)
        proposals.append(n*2)

    non_author_email = '*****@*****.**'
    non_author_id = l.add_user(non_author_email, non_author_email, non_author_email)
    l.approve_user(non_author_id)

    random.seed(0)
    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes(non_author_email, non_author_id))
    assert seen_ids == set(proposals)

    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes('*****@*****.**', users['*****@*****.**']))
    not_2_proposals = set(proposals)
    not_2_proposals.remove(4)
    assert seen_ids == not_2_proposals

    for n in range(1, 9):
        l.vote(users['*****@*****.**'], n*2, sample_vote)

    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes(non_author_email, non_author_id))
    assert seen_ids == set([18])

    l.vote(users['*****@*****.**'], 18, sample_vote)

    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes(non_author_email, non_author_id))
    assert seen_ids == set(proposals)
コード例 #7
0
ファイル: logic_test.py プロジェクト: aldeka/progcom
def test_needs_votes():
    proposals = []
    users = {}
    standards = [l.add_standard("About Pythong"), l.add_standard("Awesome")]
    sample_vote = {k: 2 for k in standards}
    for n in range(1, 10):
        prop = data.copy()
        prop["id"] = n * 2
        prop["abstract"] = "Proposal {}".format(n)
        email = "{}@example.com".format(n)
        uid = l.add_user(email, email, email)
        l.approve_user(uid)
        users[email] = uid
        prop["authors"] = [{"email": email, "name": "foo"}]
        l.add_proposal(prop)
        proposals.append(n * 2)

    non_author_email = "*****@*****.**"
    non_author_id = l.add_user(non_author_email, non_author_email, non_author_email)
    l.approve_user(non_author_id)

    random.seed(0)
    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes(non_author_email, non_author_id))
    assert seen_ids == set(proposals)

    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes("*****@*****.**", users["*****@*****.**"]))
    not_2_proposals = set(proposals)
    not_2_proposals.remove(4)
    assert seen_ids == not_2_proposals

    for n in range(1, 9):
        l.vote(users["*****@*****.**"], n * 2, sample_vote)

    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes(non_author_email, non_author_id))
    assert seen_ids == set([18])

    l.vote(users["*****@*****.**"], 18, sample_vote)

    seen_ids = set()
    for n in range(100):
        seen_ids.add(l.needs_votes(non_author_email, non_author_id))
    assert seen_ids == set(proposals)
コード例 #8
0
ファイル: logic_test.py プロジェクト: themson/progcom
def test_standards():
    assert l.get_standards() == []
    l.add_standard('Bob')
    assert l.get_standards()[0].description == 'Bob'
コード例 #9
0
ファイル: fill_db_with_fakes.py プロジェクト: cczona/progcom
def main():
    lt.transact()
    emails = ['user{}@example.com'.format(n) for n in range(50)]
    for e in emails[:25]:
        uid = l.add_user(e, '{} Person'.format(e.split('@')[0]), 'abc123')
        l.approve_user(uid)


    """
    for n in range(6):
        l.add_standard(words(3, 10)[:50])
    """
    standards = ["follows PyCon's Code of Conduct",
                "is complete, clearly written, and articulate",
                "has a thorough and achievable outline",
                "has a coherent and primarily technical subject",
                "is about the Python ecosystem",
                "has a sufficient audience among attendees"]
    for s in standards:
        l.add_standard(s)

    user_ids = [x.id for x in l.list_users()]
    standards = [x.id for x in l.get_standards()]
    
    proposal_ids = []
    for n in range(200):
        prop_id = n*2
        data = {'id': prop_id, 'authors': [{'email': random.choice(emails),
                                        'name': 'Speaker Name Here'}],
                'title': words(3,8).title(),
                'category': words(1,2),
                'duration': '30 minutes',
                'description': ipsum(4),
                'audience': ipsum(1),
                'audience_level': 'Novice',
                'notes': ipsum(2),
                'objective': ipsum(1),
                'recording_release': bool(random.random() > 0.05),
                'abstract': ipsum(1),
                'outline': ipsum(5)+"\n[test](http://www.google.com/)\n",
                'additional_notes': ipsum(1),
                'additional_requirements': ipsum(1)}
        l.add_proposal(data)
        proposal_ids.append(prop_id)

        if random.randint(0, 3) == 0:
            for n in range(random.randint(1, 10)):
                l.add_to_discussion(random.choice(user_ids), prop_id, ipsum(1))

        if random.randint(0, 2) == 0:
            for n in range(random.randint(1, 5)):
                vote = {k:random.randint(0, 2) for k in standards}
                l.vote(random.choice(user_ids), prop_id, vote)

        if random.randint(0, 3) == 0:
            data['notes'] = 'UPDATED' + ipsum(2)
            l.add_proposal(data)


    random.shuffle(proposal_ids)

    proposal_ids = proposal_ids[:70]
    for n in range(0, len(proposal_ids), 5):
        l.create_group(words(2,4).title(),
                proposal_ids[n:n+5])
コード例 #10
0
ファイル: app.py プロジェクト: themson/progcom
def add_reason():
    text = request.values.get('text')
    l.add_standard(text)
    flash('Added standard "{}"'.format(text))
    return redirect(url_for('list_standards'))
コード例 #11
0
ファイル: logic_test.py プロジェクト: njl/progcom
def test_standards():
    assert l.get_standards() == []
    l.add_standard('Bob')
    assert l.get_standards()[0].description == 'Bob'
コード例 #12
0
ファイル: logic_test.py プロジェクト: aldeka/progcom
def test_standards():
    assert l.get_standards() == []
    l.add_standard("Bob")
    assert l.get_standards()[0].description == "Bob"
コード例 #13
0
ファイル: add_standards.py プロジェクト: pybay/progcom
#!/usr/bin/env python
"""
run the whole migration as:
    psql -U test test < truncate_standards.sql && envdir dev-config ./add_standards.py
"""
import logic as l

standards = [
    "If I can only make it to 5 talks this year, I want this to be one of the 5",
    "I am pretty sure I have seen this talk before and it is great",
    "I am pretty sure I have seen this talk before and it is OK, I’d be curious to see what else is there",
    "I am pretty sure I have seen this talk before and let’s pass",
    "I can be interested in this depending on the speaker",
    "The information provided (and subsequent correspondence) did not provide enough information for me to be excited",
    "The abstract is written poorly, I have doubts they will present well enough",
]

for standard in standards:
    l.add_standard(standard)