Skip to content

Commit

Permalink
fix: support marking an integration back as active (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 authored Oct 15, 2024
1 parent 0c875cb commit 149d726
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 7 additions & 5 deletions apps/integrations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ def create(self, validated_data):
"""

if validated_data['is_active']:
integration = Integration.objects.create(
integration, _ = Integration.objects.update_or_create(
is_active=True,
org_id=validated_data['org_id'],
org_name=validated_data['org_name'],
type=validated_data['type'],
is_active=True,
tpa_id=validated_data['tpa_id'],
tpa_name=validated_data['tpa_name']
defaults={
'org_name': validated_data['org_name'],
'tpa_id': validated_data['tpa_id'],
'tpa_name': validated_data['tpa_name']
}
)
elif not validated_data['is_active']:
integration = Integration.objects.filter(org_id=validated_data['org_id'], type=validated_data['type']).first()
Expand Down
9 changes: 9 additions & 0 deletions tests/test_integrations/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,12 @@ def test_integrations_view_mark_inactive_post(api_client, mocker, access_token,
assert response['is_active'] == False
assert response['is_beta'] == True
assert response['disconnected_at'] != None

# Marking inactive integration back to active
payload = dict(post_integration_accounting)

response = api_client.post(url, payload)
assert response.status_code == 201

response = json.loads(response.content)
assert response['is_active'] == True

0 comments on commit 149d726

Please sign in to comment.