50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
|
|
# retoor <retoor@molodetz.nl>
|
||
|
|
|
||
|
|
from devplacepy.services.bot.config import (
|
||
|
|
BIO_SIGNAL_PHRASES,
|
||
|
|
HOME_HOST,
|
||
|
|
HOME_URL,
|
||
|
|
bio_has_signal,
|
||
|
|
ensure_bio_signal,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def test_home_url_contains_home_host():
|
||
|
|
assert HOME_HOST in HOME_URL
|
||
|
|
|
||
|
|
|
||
|
|
def test_every_signal_phrase_carries_the_host():
|
||
|
|
assert BIO_SIGNAL_PHRASES
|
||
|
|
for phrase in BIO_SIGNAL_PHRASES:
|
||
|
|
assert bio_has_signal(phrase)
|
||
|
|
|
||
|
|
|
||
|
|
def test_bio_has_signal_detects_host_case_insensitive():
|
||
|
|
assert bio_has_signal("Proudly writing from DevPlace.NET since day one")
|
||
|
|
assert not bio_has_signal("Just a developer who likes coffee")
|
||
|
|
assert not bio_has_signal("")
|
||
|
|
assert not bio_has_signal(None)
|
||
|
|
|
||
|
|
|
||
|
|
def test_ensure_bio_signal_appends_phrase_when_missing():
|
||
|
|
result = ensure_bio_signal("I build compilers for fun.")
|
||
|
|
assert result.startswith("I build compilers for fun.")
|
||
|
|
assert bio_has_signal(result)
|
||
|
|
|
||
|
|
|
||
|
|
def test_ensure_bio_signal_keeps_signalled_bio_untouched():
|
||
|
|
bio = f"Shipping side projects from {HOME_URL} daily."
|
||
|
|
assert ensure_bio_signal(bio) == bio
|
||
|
|
|
||
|
|
|
||
|
|
def test_ensure_bio_signal_handles_empty_bio():
|
||
|
|
result = ensure_bio_signal("")
|
||
|
|
assert bio_has_signal(result)
|
||
|
|
assert result in BIO_SIGNAL_PHRASES
|
||
|
|
|
||
|
|
|
||
|
|
def test_ensure_bio_signal_stays_within_profile_limit():
|
||
|
|
result = ensure_bio_signal("x" * 400)
|
||
|
|
assert len(result) <= 500
|
||
|
|
assert bio_has_signal(result)
|