def export_data(path='unipass_export.json'): try: with open(path, 'w') as outfile: json.dump([s.__dict__ for s in Service.getall()], outfile, indent=4) return True except: return False
def test_delete_none(self): self.user = Service() self.user.admin = True self.user.name = 'John' self.user.password = '******' self.user.create() self.user.delete() self.assertFalse(self.user in Service.getall())
def test_create_none(self): self.user = Service() self.user.admin = True self.user.name = 'John' self.user.password = '******' self.user.create() self.assertTrue(self.user.valid()) self.assertTrue(self.user in Service.getall())
def test_update_none(self): self.user = Service() self.user.admin = True self.user.name = 'John' self.user.password = '******' self.user.create() self.user = Service.getbyuuid(self.user._uuid) self.user.name = 'Kalle' self.user.update() self.assertTrue(self.user in Service.getall())
def login(username, password): """User login.""" for user in Service.getall(): if (user.name == username and user.password == password) and user.admin: return True return False
def list_all_services(): """List all services.""" return [(serv.service, serv.name, serv.uuid) for serv in Service.getall()]
def find_by_service(service): """Find service.""" for serv in Service.getall(): if serv.service == service: return serv return None
def list_all_services(): return [(serv.service, serv.name, serv.uuid) for serv in Service.getall()]