Exemple #1
0
 def test_create_same_name_user(self):
     user1 = Users.from_json(
         self.get_test_date(
             "test_create_same_name_user", "test_create_same_name_user1"))
     user2 = Users.from_json(
         self.get_test_date(
             "test_create_same_name_user", "test_create_same_name_user2"))
     self.db.create_user(self.context, user1)
     self.assertRaises(UserAlreadyExistException,
                       self.db.create_user, self.context, user2)
     self.db.delete_user(self.context, user1.phone, user1.password)
Exemple #2
0
 def test_get_user_with_incorrect_password(self):
     user = Users.from_json(
         self.get_test_date("test_get_user_with_incorrect_password"))
     n_user = self.db.create_user(self.context, user)
     self.assertRaises(IncorrectPasswordException, self.db.get_user,
                       self.context, n_user.phone, n_user.password + "_")
     self.db.delete_user(self.context, n_user.id, n_user.password)
Exemple #3
0
 def test_get_user_by_phone(self):
     user = Users.from_json(
         self.get_test_date("test_get_user_by_phone")
     )
     n_user = self.db.create_user(self.context, user)
     self.assertEqual(
         n_user,
         self.db.get_user(self.context, user.phone, user.password))
     self.db.delete_user(self.context, n_user.phone, n_user.password)
Exemple #4
0
 def setUpClass(cls):
     super(DatabaseTestCase, cls).setUpClass()
     cls.db = Database(cls.database_name)
     cls.context = Context(
         None,
         cls.db.session(),
         user=Users(id=1,
                    name="admin",
                    password="******",
                    role="admin",
                    phone="13525847457",
                    gender="man",
                    create_at=datetime.now(),
                    avatar="/path/admin/avatar.jpg",
                    enabled=True,
                    access_token="faker_token",
                    extra="{\"email\":\"emaill\"}"),
     )
Exemple #5
0
 def test_create_user(self):
     user = Users.from_json(self.get_test_date("test_create_user"))
     new_user = self.db.create_user(self.context, user)
     self.assertIsInstance(new_user, Users)
     self.db.delete_user(self.context, new_user.id, new_user.password)