# Path: extrapypi/models/user.py
# class User(db.Model):
#     ROLES = [
#         'admin',
#         'developer',
#         'installer',
#         'maintainer'
#     ]
# 
#     id = db.Column(db.Integer, primary_key=True)
#     username = db.Column(db.String(255), nullable=False, unique=True)
#     email = db.Column(db.String(255), nullable=False, unique=True)
#     password_hash = db.Column(db.String(255), nullable=False)
#     is_active = db.Column(db.Boolean, default=True)
#     role = db.Column(db.String(80), nullable=True)
# 
#     @validates('role')
#     def validate_role(self, key, role):
#         assert role in self.ROLES or role is None
#         return role
# 
#     @property
#     def is_authenticated(self):
#         return True
# 
#     @property
#     def is_anonymous(self):
#         return False
# 
#     @property
#     def is_admin(self):
#         return self.role == 'admin'
# 
#     def get_id(self):
#         try:
#             return unicode(self.id)
#         except NameError:
#             return str(self.id)
# 
#     def __repr__(self):
#         return "<User {0.username}>".format(self)
# 
# Path: extrapypi/extensions.py



from extrapypi.models import User
from extrapypi.extensions import db
    assert resp.status_code == 200

    assert user.username in resp.get_data(as_text=True)
    assert user.email in resp.get_data(as_text=True)


def test_update_user(client, user, admin_headers):
    """Test update of a user"""
    data = {
        'username': 'updated',
        'email': user.email,
        'role': 'maintainer',
        'active': 'y'
    }
    resp = client.post('/dashboard/users/%d' % user.id, headers=admin_headers,
                       data=data)
    assert resp.status_code == 302

    user = User.query.filter_by(id=user.id).first()
    assert user.username == 'updated'
    assert user.email == data['email']
    assert user.role == data['role']


def test_delete_user(client, user, admin_headers):
    """Test deletion of a user"""
    user_id = user.id
    resp = client.get('/dashboard/users/delete/%d' % user_id, headers=admin_headers)
    assert resp.status_code == 302


# Path: extrapypi/models/user.py
# class User(db.Model):
#     ROLES = [
#         'admin',
#         'developer',
#         'installer',
#         'maintainer'
#     ]
# 
#     id = db.Column(db.Integer, primary_key=True)
#     username = db.Column(db.String(255), nullable=False, unique=True)
#     email = db.Column(db.String(255), nullable=False, unique=True)
#     password_hash = db.Column(db.String(255), nullable=False)
#     is_active = db.Column(db.Boolean, default=True)
#     role = db.Column(db.String(80), nullable=True)
# 
#     @validates('role')
#     def validate_role(self, key, role):
#         assert role in self.ROLES or role is None
#         return role
# 
#     @property
#     def is_authenticated(self):
#         return True
# 
#     @property
#     def is_anonymous(self):
#         return False
# 
#     @property
#     def is_admin(self):
#         return self.role == 'admin'
# 
#     def get_id(self):
#         try:
#             return unicode(self.id)
#         except NameError:
#             return str(self.id)
# 
#     def __repr__(self):
#         return "<User {0.username}>".format(self)
# 
# Path: extrapypi/extensions.py



# Path: tests/test_views.py
from extrapypi.models import User
from extrapypi.extensions import db

    assert resp.status_code == 200

    assert user.username in resp.get_data(as_text=True)
    assert user.email in resp.get_data(as_text=True)


def test_update_user(client, user, admin_headers):
    """Test update of a user"""
    data = {
        'username': 'updated',
        'email': user.email,
        'role': 'maintainer',
        'active': 'y'
    }
    resp = client.post('/dashboard/users/%d' % user.id, headers=admin_headers,
                       data=data)
    assert resp.status_code == 302

    user = User.query.filter_by(id=user.id).first()
    assert user.username == 'updated'
    assert user.email == data['email']
    assert user.role == data['role']


def test_delete_user(client, user, admin_headers):
    """Test deletion of a user"""
    user_id = user.id
    resp = client.get('/dashboard/users/delete/%d' % user_id, headers=admin_headers)
    assert resp.status_code == 302


    assert User.query.filter_by(id=user_id).first() is None