old_contents: import bcrypt
  
  import sys
  import os
  sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../'))
  
  from scoring_engine.db import db_salt
  from scoring_engine.models.user import User
  
  sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../'))
  from helpers import generate_sample_model_tree
  from unit_test import UnitTest
  
  
  class TestUser(UnitTest):
  
      def test_init_service(self):
          user = User(username="testuser", password="testpass")
          assert user.id is None
          assert user.username == "testuser"
          assert user.password == bcrypt.hashpw("testpass".encode('utf-8'), db_salt)
          assert user.team is None
          assert user.team_id is None
          assert user.is_authenticated is True
          assert user.is_active is True
          assert user.is_anonymous is False
          assert user.get_username == 'testuser'
          assert str(user) == "<User 'testuser'>"
          assert user.get_id() == 'None'
  
      def test_basic_user(self):
          team = generate_sample_model_tree('Team', self.db)
          user = User(username="testuser", password="testpass", team=team)
          self.db.save(user)
          assert user.id is 1
          assert user.username == "testuser"
          assert user.password == bcrypt.hashpw("testpass".encode('utf-8'), db_salt)
          assert user.team is team
          assert user.team_id is team.id
          assert user.get_id() == '1'
  
new_contents: import pytest
  import bcrypt
  
  import sys
  import os
  sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../'))
  
  from scoring_engine.db import db_salt
  from scoring_engine.models.user import User
  
  sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../'))
  from helpers import generate_sample_model_tree
  from unit_test import UnitTest
  
  from sqlalchemy.exc import IntegrityError
  
  
  
  class TestUser(UnitTest):
  
      def test_init_service(self):
          user = User(username="testuser", password="testpass")
          assert user.id is None
          assert user.username == "testuser"
          assert user.password == bcrypt.hashpw("testpass".encode('utf-8'), db_salt)
          assert user.team is None
          assert user.team_id is None
          assert user.is_authenticated is True
          assert user.is_active is True
          assert user.is_anonymous is False
          assert user.get_username == 'testuser'
          assert str(user) == "<User 'testuser'>"
          assert user.get_id() == 'None'
  
      def test_basic_user(self):
          team = generate_sample_model_tree('Team', self.db)
          user = User(username="testuser", password="testpass", team=team)
          self.db.save(user)
          assert user.id is 1
          assert user.username == "testuser"
          assert user.password == bcrypt.hashpw("testpass".encode('utf-8'), db_salt)
          assert user.team is team
          assert user.team_id is team.id
          assert user.get_id() == '1'
  
      def test_username_unique(self):
          team = generate_sample_model_tree('Team', self.db)
          user1 = User(username="testuser", password="testpass", team=team)
          self.db.save(user1)
          with pytest.raises(IntegrityError):
              user2 = User(username="testuser", password="testpass", team=team)
              self.db.save(user2)
  
subject: Add test for username uniqueness