Exemplo n.º 1
0
class AdminTest(Test):
    def setUp(self):
        Test.setUp(self)
        self.user = User(username="******", password="******")
        self.user.add()
        self.view = View(view_name="Test View")
        self.view.add()
Exemplo n.º 2
0
def create_admin_user():
    from EnGo.models.permission import Permission
    from EnGo.models.user import User
    admin_permission = Permission(permission_name="Admin")
    admin_permission.add()
    admin_user = User(username="******",
                      password=generate_password_hash('0000'))
    admin_user.add()
    admin_user.add_permission(admin_permission)
Exemplo n.º 3
0
class TestGetAll(UserTest):
    def setUp(self):
        UserTest.setUp(self)
        self.user2 = User(username="******", password="******")
        self.user2.add()

    def test_should_return_list_of_all_users(self):
        users = User.get_all()

        self.assertEqual(users, [self.user, self.user2])
Exemplo n.º 4
0
def create_dev_user():
    from EnGo.models.permission import Permission
    from EnGo.models.user import User
    dev_permission = Permission.search("Dev")
    if not dev_permission:
        dev_permission = Permission(permission_name="Dev")
        dev_permission.add()
    dev_user = User(username="******", password=generate_password_hash('0000'))
    dev_user.add()
    dev_user.add_permission(dev_permission)
Exemplo n.º 5
0
class TestCommitToDb(Test):
    def setUp(self):
        Test.setUp(self)
        self.user = User(username="******", password="******")
        self.user.add()

    def test_should_save_changes_made_to_user(self):
        self.user.username = "******"
        commit_to_db()
        self.db.session.rollback()

        self.assertEqual(self.user.username, "New Name")
Exemplo n.º 6
0
class OrderTest(Test):

    def setUp(self):
        Test.setUp(self)
        self.user = User(
            username="******",
            password="******"
        )
        self.user.add()
        self.order = Order(
            user_id=self.user.id,
            title="Test Title",
            description="Test Description",
            due_date=date.today()
        )
        self.order.add()
Exemplo n.º 7
0
class UserPermissionTest(UserTest):
    def setUp(self):
        UserTest.setUp(self)
        self.admin_permission = Permission(permission_name="Admin")
        self.admin_permission.add()
        self.admin_view = View(view_name="Admin View")
        self.admin_view.add()
        self.admin_view.add_permission(self.admin_permission)
        self.admin_user = User(username="******", password="******")
        self.admin_user.add()
        self.admin_user.add_permission(self.admin_permission)
        self.quality_permission = Permission(permission_name="quality")
        self.quality_permission.add()
        self.quality_view = View(view_name="Quality View")
        self.quality_view.add()
        self.quality_view.add_permission(self.quality_permission)
        self.normal_user = User(username="******", password="******")
        self.normal_user.add()
Exemplo n.º 8
0
class UserTest(Test):
    def setUp(self):
        Test.setUp(self)
        self.user = User(username="******", password="******")
        self.user.add()
Exemplo n.º 9
0
    def test_shoul_add_permission_to_user(self):
        user = User(username="******", password="******")
        user.add()
        user.add_permission(self.quality_permission)

        self.assertIn(self.quality_permission, user.permissions)
Exemplo n.º 10
0
    def test_should_add_user(self):
        user = User(username="******", password="******")
        user.add()

        self.assertIn(user, self.db.session)