def get(self, team_name=None): """Gets the team list or application list. While ``team_name`` is specified, the application list in specified team will be responded. Otherwise, the team list will be responded. The response of team list looks like:: { "status": "SUCCESS", "message": "", "data": { "teams": [{"name": "team-1", "desc": "team-1"}, {"name": "team-2"}, "desc": "team-1"] } } And the response of application list looks like:: { "status": "SUCCESS", "message": "", "data": { "applications": ["base.foo", "base.bar"] } } :param team_name: The name of specified team. :<header Authorization: Huskar Token (See :ref:`token`) :status 404: The team with specified name is not found. :status 200: The team list or application list is responded. """ if team_name: if g.auth.is_minimal_mode: if team_name != Team.DEFAULT_NAME: abort(404, 'team "%s" does not exist' % team_name) applications = application_manifest.as_list() else: team = self._get_team_or_404(team_name) applications = Application.get_multi_by_team(team.id) applications = [x.application_name for x in applications] data = {'applications': applications} else: if g.auth.is_minimal_mode: data = {'teams': [{'name': Team.DEFAULT_NAME, 'desc': Team.DEFAULT_NAME}]} else: teams = Team.get_all() data = {'teams': [{'name': x.team_name, 'desc': x.team_desc} for x in teams]} return api_response(data)
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]