Exemplo n.º 1
0
def test_discussion():
    l.add_proposal(data)
    proposal = data["id"]

    users = []
    for n in range(10):
        uid = l.add_user("{}@example.com".format(n), "name {}".format(n), "blah")
        l.approve_user(uid)
        users.append(uid)

    l.add_to_discussion(users[0], proposal, "Lorem ipsum")

    for u in users:
        assert len(l.get_unread(u)) == 0

    assert len(l.get_discussion(proposal)) == 1
    assert l.get_discussion(proposal)[0].body == "Lorem ipsum"

    l.add_to_discussion(users[-1], proposal, "dolor sit")
    assert [x.id for x in l.get_unread(users[0])] == [proposal]
    l.add_to_discussion(users[-1], proposal, "amet, consectetur")
    assert [x.id for x in l.get_unread(users[0])] == [proposal]

    l.mark_read(users[0], proposal)
    for u in users:
        assert len(l.get_unread(u)) == 0

    l.add_to_discussion(users[0], proposal, "LOREM IPSUM")
    assert l.get_discussion(proposal)[-1].body == "LOREM IPSUM"
    assert l.get_discussion(proposal)[0].body == "Lorem ipsum"
Exemplo n.º 2
0
def test_discussion():
    l.add_proposal(data)
    proposal = data['id']

    users = []
    for n in range(10):
        uid = l.add_user('{}@example.com'.format(n), 'name {}'.format(n),
                         'blah')
        l.approve_user(uid)
        users.append(uid)

    l.add_to_discussion(users[0], proposal, 'Lorem ipsum')

    for u in users:
        assert len(l.get_unread(u)) == 0

    assert len(l.get_discussion(proposal)) == 1
    assert l.get_discussion(proposal)[0].body == 'Lorem ipsum'

    l.add_to_discussion(users[-1], proposal, 'dolor sit')
    assert [x.id for x in l.get_unread(users[0])] == [proposal]
    l.add_to_discussion(users[-1], proposal, 'amet, consectetur')
    assert [x.id for x in l.get_unread(users[0])] == [proposal]

    l.mark_read(users[0], proposal)
    for u in users:
        assert len(l.get_unread(u)) == 0

    l.add_to_discussion(users[0], proposal, 'LOREM IPSUM')
    assert l.get_discussion(proposal)[-1].body == 'LOREM IPSUM'
    assert l.get_discussion(proposal)[0].body == 'Lorem ipsum'
Exemplo n.º 3
0
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
Exemplo n.º 4
0
def test_discussion():
    l.add_proposal(data)
    proposal = data['id']

    users = []
    for n in range(10):
        uid = l.add_user('{}@example.com'.format(n), 'name {}'.format(n), 'blah')
        l.approve_user(uid)
        users.append(uid)

    l.add_to_discussion(users[0], proposal, 'Lorem ipsum')

    for u in users:
        assert len(l.get_unread(u)) == 0

    assert len(l.get_discussion(proposal)) == 1
    assert l.get_discussion(proposal)[0].body == 'Lorem ipsum'

    l.add_to_discussion(users[-1], proposal, 'dolor sit')
    assert [x.id for x in l.get_unread(users[0])] == [proposal]
    l.add_to_discussion(users[-1], proposal, 'amet, consectetur')
    assert [x.id for x in l.get_unread(users[0])] == [proposal]

    l.mark_read(users[0], proposal)
    for u in users:
        assert len(l.get_unread(u)) == 0

    l.add_to_discussion(users[0], proposal, 'LOREM IPSUM')
    assert l.get_discussion(proposal)[-1].body == 'LOREM IPSUM'
    assert l.get_discussion(proposal)[0].body == 'Lorem ipsum'
Exemplo n.º 5
0
def _add_one_proposal(id,
                      description,
                      duration,
                      audience,
                      abstract,
                      author,
                      notes,
                      title,
                      outline=None,
                      recording_release=None):
    l.add_proposal(
        dict(
            id=id,
            authors=[author] if author else [],
            description=u'Author\'s Current Location: {}\n\n{}'.format(
                author.get('location') or 'Unknown', description),
            duration=duration,
            audience=audience,
            abstract=abstract,
            recording_release=recording_release
            if recording_release is None else False,
            notes=notes,
            title=title,
            outline=outline or '',
        ))
Exemplo n.º 6
0
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
Exemplo n.º 7
0
def main():
    for id in fetch_ids():
        log.info('FETCHING {}'.format(id))
        try:
            proposal = fetch_talk(id)
            if proposal:
                l.add_proposal(proposal)
        except Exception as e:
            log.error('ERROR FETCHING {}: {}'.format(id, repr(e)))
Exemplo n.º 8
0
def test_proposal_basics():
    assert l.add_proposal(data)
    assert not l.add_proposal(data)
    assert l.get_proposal(data['id']).data['outline'] == data['outline']

    changed = data.copy()
    changed['abstract'] = 'This is a longer abstract.'

    assert l.add_proposal(changed)
Exemplo n.º 9
0
def test_proposal_basics():
    assert l.add_proposal(data)
    assert not l.add_proposal(data)
    assert l.get_proposal(data["id"]).outline == data["outline"]

    changed = data.copy()
    changed["abstract"] = "This is a longer abstract."

    assert l.add_proposal(changed)
Exemplo n.º 10
0
def test_proposal_basics():
    assert l.add_proposal(data)
    assert not l.add_proposal(data)
    assert l.get_proposal(data['id']).outline == data['outline']

    changed = data.copy()
    changed['abstract'] = 'This is a longer abstract.'

    assert l.add_proposal(changed)
Exemplo n.º 11
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])
Exemplo n.º 12
0
def main():
    existing_ids = l.get_all_proposal_ids()
    new_ids = fetch_ids()
    for id in new_ids:
        #print 'FETCHING {}'.format(id)
        proposal = fetch_talk(id)
        if proposal:
            l.add_proposal(proposal)
    withdrawn = list(set(existing_ids).difference(set(new_ids)))
    for id in withdrawn:
        l.withdraw_proposal(id)
Exemplo n.º 13
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["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])
Exemplo n.º 14
0
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)
Exemplo n.º 15
0
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)
Exemplo n.º 16
0
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)
Exemplo n.º 17
0
def test_batch():

    user = l.add_user('*****@*****.**', 'Voter', '123')
    l.approve_user(user)

    submitter = l.add_user('*****@*****.**', 'Submitted', '123')
    l.approve_user(submitter)

    proposals = []
    for n in range(1, 50):
        prop = data.copy()
        prop['id'] = n
        if n == 6:
            prop['authors'] = [{'name': 'Blah', 'email': '*****@*****.**'}]
        proposals.append(l.add_proposal(prop))

    group_one = l.create_group('Group One', proposals[4:10])
    group_two = l.create_group('Group Two', proposals[16:27])

    assert l.get_group(group_one).name == 'Group One'

    group_one_proposals = l.get_group_proposals(group_one)
    assert set(x.id for x in group_one_proposals) == set(proposals[4:10])

    all_groups = l.list_groups(user)
    assert set([group_one, group_two]) == set(x.id for x in all_groups)
    assert not any(x.voted for x in all_groups)

    votes1 = list(reversed(proposals[5:6]))
    votes2 = proposals[4:5]

    l.vote_group(group_one, user, votes1)

    all_groups = {x.id: x.voted for x in l.list_groups(user)}
    assert all_groups[group_one]
    assert not all_groups[group_two]

    assert l.get_batch_vote(group_one, user).accept == votes1

    l.vote_group(group_one, user, votes2)

    assert l.get_batch_vote(group_one, user).accept == votes2

    assert len(l.list_groups(submitter)) == 1
Exemplo n.º 18
0
def test_batch():

    user = l.add_user('*****@*****.**', 'Voter', '123')
    l.approve_user(user)

    submitter = l.add_user('*****@*****.**', 'Submitted', '123')
    l.approve_user(submitter)

    proposals = []
    for n in range(1,50):
        prop = data.copy()
        prop['id'] = n
        if n == 6:
            prop['authors'] = [{'name':'Blah', 'email':'*****@*****.**'}]
        proposals.append(l.add_proposal(prop))

    group_one = l.create_group('Group One', proposals[4:10])
    group_two = l.create_group('Group Two', proposals[16:27])

    assert l.get_group(group_one).name == 'Group One'

    group_one_proposals = l.get_group_proposals(group_one)
    assert set(x.id for x in group_one_proposals) == set(proposals[4:10])
   
    all_groups = l.list_groups(user)
    assert set([group_one, group_two]) == set(x.id for x in all_groups)
    assert not any(x.voted for x in all_groups)

    votes1 = list(reversed(proposals[5:6]))
    votes2 = proposals[4:5]

    l.vote_group(group_one, user, votes1)

    all_groups = {x.id:x.voted for x in l.list_groups(user)}
    assert all_groups[group_one]
    assert not all_groups[group_two]

    assert l.get_batch_vote(group_one, user).accept == votes1

    l.vote_group(group_one, user, votes2)

    assert l.get_batch_vote(group_one, user).accept == votes2

    assert len(l.list_groups(submitter)) == 1
Exemplo n.º 19
0
def test_batch():

    user = l.add_user("*****@*****.**", "Voter", "123")
    l.approve_user(user)

    proposals = []
    for n in range(1, 50):
        prop = data.copy()
        prop["id"] = n
        proposals.append(l.add_proposal(prop))

    group_one = l.create_group("Group One", proposals[4:10])
    group_two = l.create_group("Group Two", proposals[16:27])

    assert l.get_group(group_one).name == "Group One"

    group_one_proposals = l.get_group_proposals(group_one)
    assert set(x.id for x in group_one_proposals) == set(proposals[4:10])

    all_groups = l.list_groups(user)
    assert set([group_one, group_two]) == set(x.id for x in all_groups)
    assert not any(x.voted for x in all_groups)

    votes1 = list(reversed(proposals[5:6]))
    votes2 = proposals[4:5]

    l.vote_group(group_one, user, votes1)

    all_groups = {x.id: x.voted for x in l.list_groups(user)}
    assert all_groups[group_one]
    assert not all_groups[group_two]

    assert l.get_batch_vote(group_one, user).accept == votes1

    l.vote_group(group_one, user, votes2)

    assert l.get_batch_vote(group_one, user).accept == votes2
Exemplo n.º 20
0
def main():
    for id in fetch_ids():
        #print 'FETCHING {}'.format(id)
        proposal = fetch_talk(id)
        if proposal:
            l.add_proposal(proposal)
Exemplo n.º 21
0
def main():
    for id in fetch_ids():
        #print 'FETCHING {}'.format(id)
        proposal = fetch_talk(id)
        if proposal:
            l.add_proposal(proposal)
Exemplo n.º 22
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])
    """
    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])