def test_remove_role(self):
     self.team_owner = TeamOwner("Ben")
     self.team_owner.add_role(self.player)
     self.assertTrue(self.player in self.team_owner.roles)
     self.team_owner.remove_role(self.player)
     self.assertTrue(self.player not in self.team_owner.roles)
     self.assertRaises(ValueError, self.team_owner.remove_role, self.coach3)
 def test_add_role(self):
     self.team_owner = TeamOwner("tom")
     self.team_owner.add_role(self.player)
     self.team_owner.add_role(self.coach1)
     self.assertRaises(ValueError, self.team_owner.add_role, self.coach2)
     self.assertTrue(self.player in self.team_owner.roles)
     self.assertTrue(self.coach1 in self.team_owner.roles)
     self.assertTrue(2 == len(self.team_owner.roles))
     self.assertRaises(ValueError, self.team_owner.add_role, self.coach3)
class TestTeamOwner(TestCase):
    team_owner = TeamOwner("Oscar")
    player = Player("striker")
    coach1 = Coach("1")
    coach2 = Coach("2")
    coach3 = Coach("3")
    """ This test check getter and setter"""
    def test_remove_role(self):
        self.team_owner = TeamOwner("Ben")
        self.team_owner.add_role(self.player)
        self.assertTrue(self.player in self.team_owner.roles)
        self.team_owner.remove_role(self.player)
        self.assertTrue(self.player not in self.team_owner.roles)
        self.assertRaises(ValueError, self.team_owner.remove_role, self.coach3)

    def test_get_roles(self):
        self.team_owner.add_role(self.player)
        self.team_owner.add_role(self.coach1)
        self.assertTrue(self.player in self.team_owner.roles)
        self.assertTrue(self.coach1 in self.team_owner.roles)

    def test_add_role(self):
        self.team_owner = TeamOwner("tom")
        self.team_owner.add_role(self.player)
        self.team_owner.add_role(self.coach1)
        self.assertRaises(ValueError, self.team_owner.add_role, self.coach2)
        self.assertTrue(self.player in self.team_owner.roles)
        self.assertTrue(self.coach1 in self.team_owner.roles)
        self.assertTrue(2 == len(self.team_owner.roles))
        self.assertRaises(ValueError, self.team_owner.add_role, self.coach3)
Ejemplo n.º 4
0
 def add_team_owner(self, user_name, password, name, birth_date, assigned_by=None, additional_roles=[], using_user_id=""):
     try:
         team_owner_role = TeamOwner(assigned_by, additional_roles)
         team_owner = TeamUser(user_name, password, name, birth_date, self.__ID, role=team_owner_role)
         self.__user_data_base.add_signed_user(team_owner, 'team_owner')
         self.update_counter()
         Logger.info_log("{0}:".format(using_user_id) + "add owner: {0}".format(user_name))
     except Exception as err:
         Logger.error_log("{0}:".format(using_user_id) + err.__str__())
         raise err
class TestTeamManager(TestCase):
    team_owner = TeamOwner("Oscar")
    team_manger = TeamManager(team_owner)

    def test_set_assigned_by(self):
        self.team_manger.approve_all()
        self.assertTrue(self.team_manger.approval_open_close is True)
        self.assertTrue(self.team_manger.approval_accounting is True)
        self.assertTrue(self.team_manger.approval_add_remove is True)
        self.assertTrue(self.team_manger.approval_set_permission is True)

        self.team_manger.set_approval_add_remove(False)
        self.assertTrue(self.team_manger.approval_add_remove is False)
        self.assertTrue(self.team_manger.approval_open_close is True)
        self.assertTrue(self.team_manger.approval_accounting is True)
        self.assertTrue(self.team_manger.approval_set_permission is True)
def create_team_owner(user_dict):

    additional_roles = []

    for role_doc in user_dict['additional_roles']:
        role = doc_to_role(role_doc)
        additional_roles.append(role)

    team_owner_role = TeamOwner(user_dict['assigned_by'], additional_roles)

    team_user = TeamUser(user_dict['user_name'], user_dict['password'],
                         user_dict['name'],
                         get_birth_date_object(user_dict['birth_date']),
                         user_dict['user_id'], user_dict['team'],
                         team_owner_role)

    team_user.notifications = user_dict['notifications']

    return team_user
Ejemplo n.º 7
0
import datetime as date
from unittest import TestCase

from DataBases.TeamDB import TeamDB
from Domain.Team import Team
from Domain.TeamOwner import TeamOwner
from Domain.TeamUser import TeamUser
from Service.TeamManagementController import TeamManagementController

owner = TeamUser('user_nam2',
                 'password',
                 'NameB',
                 date.datetime(1993, 1, 12),
                 "0.0.0.2",
                 3,
                 team=None,
                 role=TeamOwner())

team_db = TeamDB()
control = TeamManagementController(team_db)
control.open_new_team("barce", None)
control.open_new_team("barce", owner)

# control.open_new_team("barca",owner)
# control.open_new_team("barca",owner)