Exemple #1
0
def populate_db(entries):
    import gjms.util.report

    import gjms.core.users as users
    import gjms.core.games as games
    import gjms.core.events as events
    import gjms.core.system as system
    import gjms.core.ratings as ratings
    import gjms.core.platforms as platforms

    import datetime
    import elixir

    start1 = datetime.datetime.today() - datetime.timedelta(days=3)
    end1 = datetime.datetime.today() - datetime.timedelta(days=1)

    start2 = datetime.datetime.today() - datetime.timedelta(days=1)
    end2 = datetime.datetime.today() + datetime.timedelta(days=1)

    start3 = datetime.datetime.today() + datetime.timedelta(days=3)
    end3 = datetime.datetime.today() + datetime.timedelta(days=5)

    system = system.get(1)

    event1 = events.add(start1, end1, "Annual Doe Jam #1", "Birds")
    event2 = events.add(start2, end2, "Annual Doe Jam #2", "Birds")
    event3 = events.add(start3, end3, "Annual Doe Jam #3", "Birds")

    system.events.append(event1)
    system.events.append(event2)
    system.events.append(event3)

    for i in range(0, entries):
        user = users.add("John Doe %s" % i, "password", "*****@*****.**")
        game = games.add("Flappy Doe %s" % i, "A Flappy Bird clone.", "http://hostagamejam.com/media/flappy-doe.png")
        rating = ratings.add(4.0)
        platform1 = platforms.add("Android", "http://hostagamejam.com/media/flappy-doe.apk")
        platform2 = platforms.add("iOS", "http://hostagamejam.com/media/flappy-doe.ipa")

        user.games.append(game)
        user.ratings.append(rating)

        game.ratings.append(rating)
        game.platforms.append(platform1)
        game.platforms.append(platform2)

        event1.participants.append(user)
        event1.games.append(game)

        system.users.append(user)
        system.games.append(game)
        system.ratings.append(rating)
        system.platforms.append(platform1)
        system.platforms.append(platform2)

        elixir.session.commit()

        gjms.util.report.output("%d of %d entries added to database." % (i+1, entries))
    return "%s - %d entries successfully added to database." % (user.system.name, entries)
Exemple #2
0
def test_add_event_correct():
    """ Test correct event adding. """

    import datetime as d

    starts = d.datetime(2014, 3, 17, 1)
    ends = d.datetime(2014, 3, 21, 1)

    event = events.add(starts, ends, "Spring Jam Week", "Some theme")
    assert type(event) == models.Event
Exemple #3
0
def test_add_event_correct():
    """ Test correct event adding. """

    import datetime as d

    starts = d.datetime(2014, 3, 17, 1)
    ends = d.datetime(2014, 3, 21, 1)

    event = events.add(starts, ends, "Spring Jam Week", "Some theme")
    assert type(event) == models.Event