Skip to content

Commit

Permalink
Fix error on end2end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acostapazo committed Nov 24, 2020
1 parent 0ffe9c4 commit 452c8ad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
6 changes: 3 additions & 3 deletions alice/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

@dataclass
class Config:
onboarding_url: str = "https://pre.alicebiometrics.com/onboarding"
sandbox_url: str = "https://pre.alicebiometrics.com/onboarding/sandbox"
auth_url: str = "https://pre.alicebiometrics.com/auth"
onboarding_url: str = "https://apis.alicebiometrics.com/onboarding"
sandbox_url: str = "https://apis.alicebiometrics.com/onboarding/sandbox"
auth_url: str = "https://apis.alicebiometrics.com/auth"
api_key: str = None
sandbox_token: str = None
send_agent: bool = True
1 change: 0 additions & 1 deletion alice/webhooks/webhooks_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def get_available_events(self, verbose: bool = False) -> Response:

backend_token = self.auth.create_backend_token().unwrap()
print_token("backend_token_with_user", backend_token, verbose=verbose)

headers = self._auth_headers(backend_token)
response = requests.get(self.url + "/events", headers=headers)

Expand Down
27 changes: 16 additions & 11 deletions tests/test_integration_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ def test_should_return_an_error_when_the_api_key_is_not_configured():
assert_failure(result)


def test_should_execute_all_webhook_lifecycle(
given_valid_api_key, given_any_valid_mail
):
def test_should_execute_all_webhook_lifecycle(given_valid_api_key):
config = Config(api_key=given_valid_api_key)
webhooks_client = Webhooks.from_config(config)

# Check Available events
available_events = webhooks_client.get_available_events().unwrap()
selected_event = available_events[0]
result = webhooks_client.get_available_events()
assert_success(result, value_is_instance_of=list)
selected_event = result.value[0]

# Create a new Webhook
webhook = Webhook(
Expand All @@ -34,7 +33,7 @@ def test_should_execute_all_webhook_lifecycle(
event_version=selected_event.get("version"),
secret=str(secrets.token_hex(20)),
)
webhook_id = webhooks_client.create_webhook(webhook).unwrap()
webhook_id = webhooks_client.create_webhook(webhook=webhook).unwrap_or_return()

# Update an existent Webhook
webhook_to_update = Webhook(
Expand Down Expand Up @@ -63,15 +62,21 @@ def test_should_execute_all_webhook_lifecycle(
result = webhooks_client.get_webhooks()
assert_success(result, value_is_instance_of=list)

# Delete a configured webhook
result = webhooks_client.delete_webhook(webhook_id)
assert_success(result)

# Retrieve las webhook result of an specific webhook
result = webhooks_client.get_last_webhook_result(webhook_id)
assert_success(result, value_is_instance_of=dict)

# Retrieve all webhook results of an specific webhook
result = webhooks_client.get_webhook_results(webhook_id)
assert_success(result, value_is_instance_of=list)
assert len(result.value) > 0

# Delete a configured webhook
result = webhooks_client.delete_webhook(webhook_id)
assert_success(result)

# Retrieve all webhook results of an specific webhook
result = webhooks_client.get_webhook_results(webhook_id)
assert_success(result, value_is_instance_of=list)
assert not any([webhook.webhook_id == webhook_id for webhook in result.value])
for webhook in result.value:
assert not webhook.get("webhook_id") == webhook_id

0 comments on commit 452c8ad

Please sign in to comment.