Beispiel #1
0
 def test_create_user(self):
     print '__________create user test_________'
     u = User(name='testbli',
              password_sha='testbli',
              email='*****@*****.**',
              activationCode='111')
     u.create()
 def add_item(self):
     State[STATE_KEY_ELEMENT] = None
     self.add_edit_dialog.init_value()
     if self.add_edit_dialog.exec():
         try:
             user = User.create({
                 'is_admin':
                 self.add_edit_dialog.isAdmin.isChecked(),
                 'name':
                 self.add_edit_dialog.userName.text(),
                 'login':
                 self.add_edit_dialog.userLogin.text(),
                 'password':
                 self.add_edit_dialog.userPassword.text(),
             })
         except Exception as e:
             # todo: хорошо бы конечно оповщение о том что пошло не так - но не в этой жизни...
             GLog.error("ui.UsersForm.add_item :: error :%s" % e)
             return
         row_number = self.table.rowCount()
         self.table.insertRow(row_number)
         self.table.setItem(row_number, 0, QTableWidgetItem(str(user.ID)))
         self.table.setItem(row_number, 1, QTableWidgetItem(user.name))
         self.table.setItem(row_number, 2, QTableWidgetItem(user.login))
         self.table.setItem(row_number, 3,
                            QTableWidgetItem('Да' if user.admin else 'Нет'))
Beispiel #3
0
def init_db():
    db.connect(reuse_if_open=True)
    db.create_tables([File, FileState, User])
    FileState.create(state="Загружается", r_accessible=False)
    FileState.create(state="Загружен")
    FileState.create(state="Кодируется", r_accessible=False)
    FileState.create(state="Закодирован")
    FileState.create(state="Удален", r_accessible=False, d_accessible=False)
    pkey = generate_key()
    u = User.create(auth_token=uuid4(), pkey=pkey)
    app.logger.info("First user: %s" % u.auth_token)
    db.commit()
Beispiel #4
0
 def test_entity_manipulation(self):
   switchToTestDatabase()
   #creating a user
   u=User(login='******',password='******')   
   print User.create(u) , '\n'
   self.assertTrue(u.findByLogin()!= None)
 
   #finding & updating a user
   u=User(login='******')
   u=u.findByLogin()
   print 'user before update: ', u
   print 'changing password to strong'
   u.password='******'
   u.update()
   u=u.findByLogin()
   print u
   self.assertEqual(u.password,'strong')
   print 'changing password to VERYstrong'
   u.password='******'
   u.update()
   u=u.findByLogin()
   print u
   self.assertEqual(u.password,'VERYstrong')
 
   #try to update a non existing user
   raised=False
   
   try :
     u=User(login='******',password='******')
     u.update()
   except Exception :
     print 'catch an Illegal Attempt'
     print '\ntrying to update jose, but he don\'t exist'
     raised=True
   self.assertTrue(raised)
   self.assertEqual(u.findByLogin(),None)
   
   
   deleteTestDatabase()
Beispiel #5
0
 def test_create_user(self):
     print "__________create user test_________"
     u = User(name="testbli", password_sha="testbli", email="*****@*****.**", activationCode="111")
     u.create()