def create_guestuser(self): guest = User() guest.username = '******' guest.first_name = 'Guest' guest.last_name = 'User' guest.set_password('guest') guest.is_staff = True guest.save() # add permissions for table in ['session', 'collection', 'userprofile', 'deviceprofile']: for code in ['add', 'change', 'delete']: code_name = code + '_' + table permission = Permission.objects.get(codename=code_name) guest.user_permissions.add(permission) # create default model profile = UserProfile(user=guest, module='ietf-interfaces@2013-12-23') profile.save() # add default collection col = Collection(name='default', user=guest, description='Default Collection') col.save()
def create_guestuser(self, cxmldir): guest = User() guest.username = '******' guest.first_name = 'Guest' guest.last_name = 'User' guest.set_password('guest') guest.is_staff = True guest.save() # add permissions for table in ['session', 'collection', 'userprofile', 'deviceprofile']: for code in ['add', 'change', 'delete']: code_name = code + '_' + table permission = Permission.objects.get(codename=code_name) guest.user_permissions.add(permission) # create list of model if cxmldir: for f in os.listdir(cxmldir): f_split = os.path.splitext(f) if f_split[1] == '.xml': profile = UserProfile(user=guest, module=os.path.basename(f_split[0])) profile.save() else: profile = UserProfile(user=guest, module='ietf-interfaces@2013-12-23') profile.save() # add default collection col = Collection(name='default', user=guest, description='Default Collection') col.save()
def setUp(self): demo = User() demo.username = '******' demo.first_name = 'Demo' demo.last_name = 'Last' demo.set_password('demo123') demo.is_staff = False demo.save() self.user = demo self.user_path = os.path.join('data', 'users', 'demo') self.chrome = Client() self.upload_files = []