Beispiel #1
0
def config_user_edit():
    #print(request.form)
    user_name = request.form.getlist("user")[0]
    password = request.form.getlist("password")[0]
    user = Users()
    user.add_user(user_name, password)
    kif()
    return render_template('config_user.html', users=user.get_users())
Beispiel #2
0
      def test_add_multiple_users(self):
          '''
          test for posibility of adding many users to user_list
          '''

          self.new_user.add_user()
          test_user = Users("Moringa", "1234")
          test_user.add_user()
          self.assertEqual(len(Users.users_list), 2)
Beispiel #3
0
      def test_user_exists(self):
          '''
          test if a user exists or not
          '''
          self.new_user.add_user()
          test_user = Users("Moringa", "1234")
          test_user.add_user()

          user_exists = Users.user_exists("Moringa","1234")
          self.assertTrue(user_exists)
Beispiel #4
0
      def test_search_username(self):
          '''
          test finding user via username logic
          '''
          self.new_user.add_user()
          test_user = Users("Moringa", "1234")
          test_user.add_user()

          found_user = Users.search_username("Moringa")
          self.assertEqual(found_user.login_password, test_user.login_password)
Beispiel #5
0
      def test_delete_user(self):
          '''
          test for removing users from users_list
          '''

          self.new_user.add_user()
          test_user = Users("Moringa", "1234")
          test_user.add_user()

          test_user.delete_user()
          self.assertEqual(len(Users.users_list),1)
Beispiel #6
0
 def _register(self):
     username = self.content['username']
     if Users.user_exists(username):
         self.status = ResponseCreator.status_codes['LOGIN_NOT_AVAILABLE']
         return
     password = self.content['password']
     public_key = self.content['public_key']
     email = self.content['email']
     usr = User(username=username,
                password=Encryptor.hash_message(password.encode()).decode(),
                email=email)
     Users.add_user(usr)
     UsersToPublicKeys.add_user_public_key(username, public_key)
Beispiel #7
0
def post():
    if request.method == 'POST':
        print(request.form)
        clients = Users.add_user(request.form["number"],
                                 request.form["firstname"],
                                 request.form["lastname"],
                                 request.form["midname"],
                                 request.form["birthday"])
    return render_template('post_user.html',
                           title="Добавление пользователя",
                           menu=menu)
Beispiel #8
0
def users_test():
    users = Users()
    users.add_user(1, "milo@com", "tratata", "Katya", "Korolchuk",
                   "developer", "picture", "active")
Beispiel #9
0
class TestingUsers(unittest.TestCase):
      '''
      class that defines Users class test cases
      
      Args:
        unittest.Testcase: aids in creating test cases
      '''
      def setUp(self):
          '''
          method that runs before each test case
          '''
          self.new_user = Users("Burence","1997")

      def test_init(self):
          '''
          test proper object initialization
          '''
          self.assertEqual(self.new_user.username,"Burence")
          self.assertEqual(self.new_user.login_password,"1997")

      def test_add_user(self):
          '''
          test if added user is saved to users_list
          '''

          self.new_user.add_user()
          self.assertEqual(len(Users.users_list),1)

      def tearDown(self):
          '''
          clear user_list after each round of test
          '''

          Users.users_list = []

      def test_add_multiple_users(self):
          '''
          test for posibility of adding many users to user_list
          '''

          self.new_user.add_user()
          test_user = Users("Moringa", "1234")
          test_user.add_user()
          self.assertEqual(len(Users.users_list), 2)

      def test_delete_user(self):
          '''
          test for removing users from users_list
          '''

          self.new_user.add_user()
          test_user = Users("Moringa", "1234")
          test_user.add_user()

          test_user.delete_user()
          self.assertEqual(len(Users.users_list),1)
          
      def test_search_username(self):
          '''
          test finding user via username logic
          '''
          self.new_user.add_user()
          test_user = Users("Moringa", "1234")
          test_user.add_user()

          found_user = Users.search_username("Moringa")
          self.assertEqual(found_user.login_password, test_user.login_password)

      def test_user_exists(self):
          '''
          test if a user exists or not
          '''
          self.new_user.add_user()
          test_user = Users("Moringa", "1234")
          test_user.add_user()

          user_exists = Users.user_exists("Moringa","1234")
          self.assertTrue(user_exists)
Beispiel #10
0
 def test_b_add_user(self):
     c = self.check_count()
     Users.add_user(5, 'Ульрих', 'Иванович', 'Ципляев', '2020-02-02')
     self.assertGreater(self.check_count(), c)