def test_add_slack_api_error(mock_get): with fake_creds(): creds = { "WEBAPP_URL": "https://staging.jovian.ml/", "GUEST_KEY": "b6538d4dfde04fcf993463a828a9cec6", "API_URL": "https://api-staging.jovian.ai", "API_KEY": "fake_invalid_api_key", "ORG_ID": "staging", } write_creds(creds) with pytest.raises(ApiError): add_slack()
def test_add_slack_api_error(self, mock_get): with fake_creds('.jovian-add-slack', 'credentials.json'): # setUp creds = { "WEBAPP_URL": "https://staging.jovian.ml/", "GUEST_KEY": "b6538d4dfde04fcf993463a828a9cec6", "API_URL": "https://api-staging.jovian.ai", "API_KEY": "fake_invalid_api_key", "ORG_ID": "staging" } write_creds(creds) with self.assertRaises(ApiError): add_slack()
def test_add_slack(mock_requests_get, api_key, expected_result, capsys): with fake_creds(): creds = { "WEBAPP_URL": "https://staging.jovian.ml/", "GUEST_KEY": "b6538d4dfde04fcf993463a828a9cec6", "API_URL": "https://api-staging.jovian.ai", "API_KEY": api_key, "ORG_ID": "staging", } write_creds(creds) add_slack() captured = capsys.readouterr() assert captured.out.strip() == expected_result
def test_add_slack_errors(mock_get, capsys): with fake_creds('.jovian-add-slack', 'credentials.json'): # setUp creds = { "WEBAPP_URL": "https://staging.jovian.ml/", "GUEST_KEY": "b6538d4dfde04fcf993463a828a9cec6", "API_URL": "https://api-staging.jovian.ai", "API_KEY": "fake_api_key_error", "ORG_ID": "staging" } write_creds(creds) add_slack() captured = capsys.readouterr() assert captured.out.strip() == "[jovian] Invalid guest key"
def test_add_slack(mock_get, capsys): with fake_creds('.jovian-add-slack', 'credentials.json'): # setUp creds = { "WEBAPP_URL": "https://staging.jovian.ml/", "GUEST_KEY": "b6538d4dfde04fcf993463a828a9cec6", "API_URL": "https://api-staging.jovian.ai", "API_KEY": "fake_api_key", "ORG_ID": "staging" } write_creds(creds) add_slack() captured = capsys.readouterr() assert captured.out.strip() == "[jovian] Slack already connected." + \ " \nWorkspace: jovian.ml\nConnected Channel: @rohit"
def exec_add_slack(ctx): """Connect slack to get updates.""" add_slack()