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()
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
def __init__(self, _id, owner, auth, last_ping=None, **kwargs): owner = User.load(owner)['_id'] super(Machine, self).__init__(_id=_id, owner=owner, auth=auth, last_ping=last_ping, **kwargs)
def __init__(self, source, version, owner, dsc, group=None, **kwargs): owner = User.load(owner)['_id'] super(Source, self).__init__(source=source, version=version, group=group, owner=owner, dsc=dsc, **kwargs)
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'
def get_owner(self): return User.load(self['owner'])