Exemplo n.º 1
0
 def test_get_all_simple_users(self):
     """
     Ensure get all simple users behaves correctly.
     """
     add_simple_user(simple_user_dict)
     add_simple_user(simple_user_dict2)
     with self.client:
         response = self.client.get("/users/simple")
         data = json.loads(response.data.decode())
         self.assertEqual(response.status_code, 200)
         self.assertEqual(len(data["simple_users"]), 2)
         self.assertIn(
             "*****@*****.**", data["simple_users"][0]["email"]
         )
         self.assertIn(
             "*****@*****.**", data["simple_users"][1]["email"]
         )
Exemplo n.º 2
0
 def test_get_simple_user(self):
     """
     Ensure get single user behaves correctly.
     """
     simple_user = add_simple_user(simple_user_dict)
     with self.client:
         response = self.client.get(f"/users/simple/{simple_user.id}")
         data = json.loads(response.data.decode())
         self.assertEqual(response.status_code, 200)
         self.assertEqual(
             simple_user.email,
             data["simple_user"]["email"]
         )
 def test_to_dict(self):
   user = add_simple_user(simple_user_dict)
   self.assertTrue(isinstance(user.to_dict(), dict))
 def test_add_user_duplicate_email(self):
     add_simple_user(simple_user_dict)
     duplicate_user = SimpleUser(**simple_user_dict)
     db.session.add(duplicate_user)
     self.assertRaises(IntegrityError, db.session.commit)
 def test_add_simple_user(self):
     user = add_simple_user(simple_user_dict)
     self.assertTrue(user.id)
     self.assertEqual(user.email, '*****@*****.**')
     self.assertTrue(user.online)
Exemplo n.º 6
0
def seed_db():
    """Seeds the database."""
    add_simple_user(simple_user_dict)
    add_simple_user(simple_user_dict2)
    add_user(user_dict)
    add_user(user_dict2)