Esempio n. 1
0
def db_setup(app):
    session = app.db.session('relengapi')
    machines = []
    for m in (("127.0.0.1", "host1.mozilla.org"),
              ("127.0.0.2", "host2.mozilla.org"), ("127.0.0.3",
                                                   "host3.mozilla.org"),
              ("127.0.0.4", "host4.mozilla.org"), ("127.0.0.5",
                                                   "host5.mozilla.org")):
        machines.append(Machines(ipaddress=m[0], fqdn=m[1]))
    session.add_all(machines)

    humans = []
    for u in (("*****@*****.**", "*****@*****.**"),
              ("*****@*****.**", "*****@*****.**"),
              ("*****@*****.**", "*****@*****.**"),
              ("*****@*****.**", "*****@*****.**")):
        humans.append(Humans(ldap=u[0], bugzilla=u[1]))
    session.add_all(humans)

    loans = []
    for l in (  # status, bug, machine, human
        ("ACTIVE", 1234001, machines[0],
         humans[0]), ("COMPLETE", 1234002, machines[1],
                      humans[1]), ("PENDING", 1234003, machines[2], humans[2]),
        ("ACTIVE", 1234004, machines[3],
         humans[0]), ("ACTIVE", 1234005, machines[4],
                      humans[1]), ("PENDING", 1234006, None, humans[0])):
        loans.append(Loans(status=l[0], bug_id=l[1], machine=l[2], human=l[3]))
    session.add_all(loans)

    # XXX History Tests
    # XXX ManualAction Tests
    # _ = (History, ManualActions)  # silence pyflakes
    session.commit()