예제 #1
0
 def test_update_team_when_it_doesnt_exists(self, session):
     test_new_title = "test_new_title"
     test_team_id = 1
     with pytest.raises(TeamManagerException) as exc:
         TeamManager(session).update(team_id=test_team_id,
                                     new_title=test_new_title)
     assert EXC_TEAM_DOESNT_EXISTS.format(test_team_id) in str(exc.value)
예제 #2
0
 def test_attach_team_when_it_doesnt_exists(self, session):
     test_team_id = 1
     test_services_group_id = 2
     with pytest.raises(TeamManagerException) as exc:
         TeamManager(session).attach_to_services_group(
             team_id=test_team_id, services_group_id=test_services_group_id)
     assert EXC_TEAM_DOESNT_EXISTS.format(test_team_id) in str(exc.value)
예제 #3
0
 def test_detach_team_when_services_group_doesnt_exists(self, session):
     test_services_group_id = 4
     with pytest.raises(TeamManagerException) as exc:
         TeamManager(session).detach_from_services_group(
             services_group_id=test_services_group_id)
     assert EXC_SERVICES_GROUP_DOESNT_EXISTS.format(
         test_services_group_id) in str(exc.value)
예제 #4
0
 def test_detach_team(self, session, create_project_team_test_data):
     test_services_group_id = 4
     TeamManager(session).detach_from_services_group(
         services_group_id=test_services_group_id)
     services_group_team_id = (session.query(
         ServicesGroup.team_id).filter_by(
             id=test_services_group_id).scalar())
     assert services_group_team_id is None
예제 #5
0
 def test_attach_team_when_services_group_doesnt_exists(
         self, session, create_project_team_test_data):
     test_team_id = 1
     test_services_group_id = 201
     with pytest.raises(TeamManagerException) as exc:
         TeamManager(session).attach_to_services_group(
             team_id=test_team_id, services_group_id=test_services_group_id)
     assert EXC_SERVICES_GROUP_DOESNT_EXISTS.format(
         test_services_group_id) in str(exc.value)
예제 #6
0
 def test_attach_team(self, session, create_project_team_test_data):
     test_team_id = 1
     test_services_group_id = 2
     TeamManager(session).attach_to_services_group(
         team_id=test_team_id, services_group_id=test_services_group_id)
     services_group_team_id = (session.query(
         ServicesGroup.team_id).filter_by(
             id=test_services_group_id).scalar())
     assert services_group_team_id == test_team_id
예제 #7
0
    def test_update_team(self, session, create_project_team_test_data):
        test_new_title = "test_new_title"
        test_team_id = 1

        TeamManager(session).update(team_id=test_team_id,
                                    new_title=test_new_title)
        team_title = (session.query(
            Team.title).filter_by(id=test_team_id).scalar())
        assert team_title == test_new_title
예제 #8
0
    def dispatch_request(self):
        data_for_delete = json.loads(request.data)

        if "id" in data_for_delete:
            try:
                valid_data_for_delete = UpdateProjectTeamModel(
                    **data_for_delete)
            except ValidationError as e:
                return jsonify({"error": e.errors()}), 400
            try:
                TeamManager(
                    db.session).delete(team_id=valid_data_for_delete.id)
            except TeamManagerException as exc:
                return jsonify({"error": exc.error_text}), 400
            return jsonify({"success": True})
        return jsonify({"error": EXC_FIELD_IS_REQUIRED.format("id")}), 400
예제 #9
0
    def dispatch_request(self):
        data_for_create = json.loads(request.data)

        if "title" in data_for_create:
            try:
                valid_data_for_create = UpdateProjectTeamModel(
                    **data_for_create)
            except ValidationError as e:
                return jsonify({"error": e.errors()}), 400
            try:
                new_team = TeamManager(
                    db.session).create(title=valid_data_for_create.title)
            except TeamManagerException as exc:
                return jsonify({"error": exc.error_text}), 400
            return jsonify({
                "success": True,
                "id": new_team.id,
                "title": new_team.title
            })
        return jsonify({"error": EXC_FIELD_IS_REQUIRED.format("title")}), 400
예제 #10
0
    def dispatch_request(self):
        data_for_detach = json.loads(request.data)

        for parameter in PARAMETERS_DETACH_PROJECT_TEAM:
            if parameter not in data_for_detach:
                return (
                    jsonify({"error":
                             EXC_FIELD_IS_REQUIRED.format(parameter)}),
                    400,
                )
        try:
            valid_data_for_detach = AttachDetachProjectTeamModel(
                **data_for_detach)
        except ValidationError as e:
            return jsonify({"error": e.errors()}), 400
        try:
            TeamManager(db.session).detach_from_services_group(
                services_group_id=valid_data_for_detach.services_group_id)
        except TeamManagerException as exc:
            return jsonify({"error": exc.error_text}), 400
        return jsonify({"success": True})
예제 #11
0
    def dispatch_request(self):
        data_for_update = json.loads(request.data)

        for parameter in PARAMETERS_PROJECT_TEAM:
            if parameter not in data_for_update:
                return (
                    jsonify({"error":
                             EXC_FIELD_IS_REQUIRED.format(parameter)}),
                    400,
                )
        try:
            valid_data_for_update = UpdateProjectTeamModel(**data_for_update)
        except ValidationError as e:
            return jsonify({"error": e.errors()}), 400
        try:
            TeamManager(db.session).update(
                team_id=valid_data_for_update.id,
                new_title=valid_data_for_update.title,
            )
        except TeamManagerException as exc:
            return jsonify({"error": exc.error_text}), 400
        return jsonify({"success": True})
예제 #12
0
 def test_delete_team(self, session, create_project_team_test_data):
     test_team_id = 1
     TeamManager(session).delete(team_id=test_team_id)
     assert not session.query(
         exists().where(Team.id == test_team_id)).scalar()
예제 #13
0
 def test_create_team_with_exists_title(self, session,
                                        create_project_team_test_data):
     test_title = "test_team_1"
     with pytest.raises(TeamManagerException) as exc:
         TeamManager(session).create(title=test_title)
     assert EXC_TEAM_ALREADY_EXISTS.format(test_title) in str(exc.value)
예제 #14
0
 def test_create_team(self, session):
     test_title = "test_team_1"
     TeamManager(session).create(title=test_title)
     assert session.query(exists().where(Team.title == test_title)).scalar()