Esempio n. 1
0
File: init.py Progetto: paultag/lucy
def main():
    if not args.files:
        raise Exception("WTF - need a config")

    config = args.files.pop(0)
    obj = json.load(open(config, 'r'))

    machines = obj['machines']
    configs = obj['configs']
    users = obj['users']

    puts("Loading users:")
    for conf in progress.bar(users):
        u = User(**conf)
        u.save()

    puts("Loading machines:")
    for conf in progress.bar(machines):
        m = Machine(**conf)
        m.save()

    puts("Loading configs:")
    for conf in progress.bar(configs):
        c = Config(**conf)
        c.save()
Esempio n. 2
0
def test_basic_user_foo():
    """ Test that user routines works """

    u = User(_id='joe',
             name='Joe Bar',
             gpg="8F049AD82C92066C7352D28A7B585B30807C2A87",
             email="*****@*****.**")

    assert 'joe' == u.save()
    u.save()

    joe = User.get_by_email('*****@*****.**')

    joe.pop('updated_at')
    u.pop('updated_at')

    assert joe == u

    joe = User.get_by_key("8F049AD82C92066C7352D28A7B585B30807C2A87")

    joe.pop('updated_at')

    assert joe == u

    try:
        joe = User.get_by_key("foo")
        assert True is False, "KeyCheck failed"
    except KeyError:
        pass
Esempio n. 3
0
def test_basic_source():
    """ Test that source routines works """
    User(_id='joe', name='', email='', gpg='').save()

    p = Source(source='fluxbox', version='1.0', owner="joe")
    p.save()

    p = Source(source='fluxbox', version='2.0', owner="joe")
    p.save()

    p = Source(source='frucksbox', version='2.0', owner="joe")
    x = p.save()

    obj = Source.load(x)
    assert obj['version'] == '2.0'