Exemplo n.º 1
0
def test_create_team(db):
    team = Team.create('bar')
    assert team.id > 0
    assert team.team_name == 'bar'

    with raises(NameOccupiedError):
        Team.create('bar')  # name conflicts

    team = Team.create('baz')
    assert team.team_name == 'baz'
Exemplo n.º 2
0
def test_application_transfer_team(db, test_application, faker):
    orig_team_id = test_application.team_id
    dest_team = Team.create(faker.name())
    test_application.transfer_team(dest_team.id)
    application = Application.get_by_name(test_application.application_name)
    assert application.team_id == dest_team.id
    assert test_application.id not in Application.get_ids_by_team(orig_team_id)
    assert test_application.id in Application.get_ids_by_team(dest_team.id)
Exemplo n.º 3
0
    def post(self):
        """Creates a new team.

        :form team: The name of creating team.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :status 400: The name is invalid.
        :status 200: The team with specified name exists.
        :status 201: The team with specified name is created successfully.
        """
        g.auth.require_admin('only admin can add team')
        team_name = request.form['team'].strip()
        team = Team.get_by_name(team_name)
        if team is not None:
            return api_response(), 200

        try:
            team = Team.create(team_name)
        except NameOccupiedError:
            abort(400, 'Team %s has been archived.' % team_name)
        audit_log.emit(audit_log.types.CREATE_TEAM, team=team)
        return api_response(), 201
Exemplo n.º 4
0
def team():
    return Team.create('foobar')
Exemplo n.º 5
0
def fake_team(db, faker):
    return Team.create(faker.uuid4()[:8], faker.uuid4()[:8])
Exemplo n.º 6
0
def test_get_all_teams(db, team_foo, team_bar):
    assert Team.get_all() == [team_foo, team_bar]

    team_baz = Team.create('baz')

    assert Team.get_all() == [team_foo, team_bar, team_baz]
Exemplo n.º 7
0
def team_bar(db):
    return Team.create('bar')
Exemplo n.º 8
0
def team_foo(db):
    return Team.create('foo')
Exemplo n.º 9
0
 def ensure_team(self):
     return Team.get_by_name(self.department.team_name) or Team.create(
         self.department.team_name, self.department.team_desc)
Exemplo n.º 10
0
def test_team(db, faker):
    team_name = 'test_%s' % faker.uuid4()[:8]
    return Team.create(team_name)