Skip to content

Commit

Permalink
Merge pull request #63 from ologbonowiwi/fix/#62/fallback-empty-value…
Browse files Browse the repository at this point in the history
…s-to-show-on-console

Fallback to empty values to show on the console in case the profile doesn't
have them.

FIX #62

Signed-off-by: Ayush Joshi <[email protected]>
  • Loading branch information
joshiayush committed May 8, 2023
2 parents da7555b + 69ee9d4 commit 962e450
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
10 changes: 8 additions & 2 deletions inb/api/invitation/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,14 @@ def _replace_template_var_with_template_value(
the template variables.
"""
for replace_template_var_with_value_pair in replace_template_var_with:
message_template = message_template.replace(
*replace_template_var_with_value_pair)
template_var = replace_template_var_with_value_pair[0]
template_value = replace_template_var_with_value_pair[1]

if template_value is not None:
message_template = message_template.replace(
template_var, template_value)
else:
message_template = message_template.replace(template_var, 'NaN')
return message_template

def _fill_search_message_template(self) -> str:
Expand Down
27 changes: 27 additions & 0 deletions inb/tests/test_invitation_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,33 @@ def test_invitation_send_status_to_console(invitation):
])


def test_invitation_send_status_to_console_with_empty_values(invitation):
status._SUCCESS_RATE = 0
status._FAILURE_RATE = 0

invitation.set_invitation_fields(
name='John Smith',
occupation=None,
location=None,
profileid='john-smith',
profileurl='https://www.linkedin.com/in/john-smith',
status='sent',
elapsed_time=10.0)

expected_output = (' ✔ John Smith\n'
' NaN\n'
' NaN\n'
' Success: 1 Failure: 0 Elapsed time: 10.0s\n')

with mock.patch('click.echo') as mk_click_echo:
invitation._send_status_to_console()
mk_click_echo.assert_has_calls([
mock.call('', sys.stdout, True, True),
mock.call(expected_output, sys.stdout, True, True),
mock.call('', sys.stdout, True, True)
])


@pytest.fixture
def mock_sleep():
with mock.patch('time.sleep') as mk_sleep:
Expand Down

0 comments on commit 962e450

Please sign in to comment.