Exemplo n.º 1
0
 def serialize(self, obj, attrs, user):
     provider = ExternalTeam.get_provider_string(obj.provider)
     return {
         "id": str(obj.id),
         "teamId": str(obj.team_id),
         "provider": provider,
         "externalName": obj.external_name,
     }
Exemplo n.º 2
0
 def test_create_existing_association(self):
     self.external_team = ExternalTeam.objects.create(
         team_id=str(self.team.id),
         provider=ExternalTeam.get_provider_enum("github"),
         external_name="@getsentry/ecosystem",
     )
     data = {
         "externalName":
         self.external_team.external_name,
         "provider":
         ExternalTeam.get_provider_string(self.external_team.provider),
     }
     response = self.client.post(self.url, data)
     assert response.status_code == 200
     assert response.data == {
         "id": str(self.external_team.id),
         "teamId": str(self.external_team.team_id),
         **data,
     }
Exemplo n.º 3
0
 def setUp(self):
     super().setUp()
     self.login_as(user=self.user)
     self.org = self.create_organization(owner=self.user, name="baz")
     self.team = self.create_team(organization=self.org, name="Mariachi Band")
     self.external_team = ExternalTeam.objects.create(
         team_id=str(self.team.id),
         provider=ExternalTeam.get_provider_enum("github"),
         external_name="@getsentry/ecosystem",
     )
     self.url = reverse(
         "sentry-api-0-external-team-details",
         args=[self.org.slug, self.team.slug, self.external_team.id],
     )
Exemplo n.º 4
0
    def create_external_team(team, **kwargs):
        kwargs.setdefault("provider", ExternalTeam.get_provider_enum("github"))
        kwargs.setdefault("external_name", "@getsentry/ecosystem")

        return ExternalTeam.objects.create(team=team, **kwargs)
Exemplo n.º 5
0
 def validate_provider(self, provider):
     if provider not in EXTERNAL_PROVIDERS.values():
         raise serializers.ValidationError(
             f'The provider "{provider}" is not supported. We currently accept GitHub and GitLab team identities.'
         )
     return ExternalTeam.get_provider_enum(provider)