Пример #1
0
 def test_number_of_admins(self):
     signed_user_controller = SignedUserController()
     d1 = datetime.datetime(2020, 4, 23)
     d2 = datetime.datetime(2020, 4, 23)
     self.assertEqual(0, signed_user_controller.number_of_admins())
     signed_user_controller.add_system_admin("name_u1", "1234", "ro", d1,
                                             "0.0.0.5")
     signed_user_controller.add_system_admin("name_u21", "1234", "rso", d2,
                                             "0.0.0.2")
     signed_user_controller.add_fan_to_data("name_u2221", "12334", "rowe",
                                            d2, "0.0.0.1")
     self.assertEqual(2, signed_user_controller.number_of_admins())
Пример #2
0
 def test_confirm_user(self):
     signed_user_controller = SignedUserController()
     d1 = datetime.datetime(2020, 4, 23)
     signed_user_controller.add_system_admin("name_u1", "1234", "ro", d1,
                                             "0.0.0.5")
     self.assertEqual(
         "SystemAdmin",
         signed_user_controller.confirm_user("name_u1", "1234"))
     self.assertFalse(
         signed_user_controller.confirm_user("name_u1", "12345"))
     self.assertFalse(signed_user_controller.confirm_user(
         "name_u2", "1234"))
Пример #3
0
 def test_add_system_admin(self):
     """
     test if the admin in the DB
     If we ran all test its check that ID of the guest is not getting up when we got same guest
     @return:
     """
     signed_user_controller = SignedUserController()
     signed_user_controller.add_guest("0.0.0.1")
     d = datetime.datetime(2020, 4, 23)
     signed_user_controller.add_system_admin("name_u0", "1234", "ro", d,
                                             "0.0.0.5")
     self.assertIsNotNone(
         signed_user_controller.get_signed_users().get("name_u0"))
Пример #4
0
class System:
    def __init__(self, admin_user_name, admin_password, admin_name,
                 admin_birth_date, admin_ip):
        self.complaint_db = ComplaintDB()
        self.game_db = GameDB()
        self.league_db = LeagueDB()
        self.season_DB = SeasonDB()
        self.team_db = TeamDB()
        self.user_db = UserDB()
        self.policy_db = PolicyDB()

        self.union_organization = UnionOrganization()

        self.complaint_controller = ComplaintController(self.complaint_db)
        self.league_controller = LeagueController(self.league_db,
                                                  self.season_DB, PolicyDB)
        self.match_controller = MatchController(self.game_db)
        self.user_controller = SignedUserController(self.user_db)
        self.team_controller = TeamManagementController(self.team_db)
        self.union_controller = UnionController(self.union_organization)

        self.user_controller.add_system_admin(admin_user_name, admin_password,
                                              admin_name, admin_birth_date,
                                              admin_ip)
""" This class is the controller that connects the server to the Domain """

users_db = MongoUserDB()
team_db = MongoTeamDB()
policy_db = MongoPolicyDB()
league_db = MongoLeagueDB()
season_db = MongoSeasonDB()
game_db = MongoGameDB()
game_event_db = MongoGameEventDB()
league_controller = LeagueController(league_db, season_db, users_db, policy_db)
signed_user_controller = SignedUserController(users_db)
notification_controller = NotificationController(users_db, game_db)
team_management_controller = TeamManagementController(team_db, users_db)
match_controller = MatchController(game_db, users_db, game_event_db, team_db)
if not signed_user_controller.confirm_user('dor', '1234'):
    signed_user_controller.add_system_admin('dor', '1234', 'dor',
                                            date.datetime(1994, 1, 20))

try:
    signed_user_controller.add_team_owner('shahar', '1234', 'shahar',
                                          date.datetime(1993, 1, 1))
    signed_user_controller.add_referee(RefereeQualificationEnum.MAIN, 'oscar',
                                       '1234', 'oscar',
                                       date.datetime(1994, 11, 9))
    main_referee = signed_user_controller.get_user_by_name('oscar')
    owner = signed_user_controller.get_user_by_name('shahar')

    team_management_controller.open_new_team('Brca', owner.user_id)
    team_management_controller.open_new_team('Real', owner.user_id)

    match_controller.add_game('Brca', 'Real', date.datetime.now(), 'S',
                              main_referee.user_id)