Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions tests/test_get_username_from_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import pytest
import yaml
import scraper
from scraper import get_username_from_url


@pytest.fixture
def config_data():
with open("config.yml") as f:
config = yaml.load(f, Loader=yaml.SafeLoader)
return config

def test_matched_host_urls(config_data):
# set global variable
scraper.config = config_data

# Linux Action News
assert get_username_from_url("/hosts/drewdvore") == "drew-devore"

# Coder
assert get_username_from_url("/hosts/chrislas") == "chris"
assert get_username_from_url("/hosts/wespayne") == "wes"

# Extras
assert get_username_from_url("/hosts/alexktz") == "alex"

# Office Hours
assert get_username_from_url("/hosts/brentgervais") == "brent"

def test_unmatched_host_urls(config_data):
# set global variable
scraper.config = config_data

# Linux Action News
assert get_username_from_url("/hosts/chris") == "chris"
assert get_username_from_url("/hosts/joe") == "joe"
assert get_username_from_url("/hosts/wes") == "wes"

# Coder
assert get_username_from_url("/hosts/michael") == "michael"

def test_matched_guests_urls(config_data):
# set global variable
scraper.config = config_data

# Selfhosted
assert get_username_from_url("/guests/alanpope") == "popey"

# Linux Unplugged
assert get_username_from_url("https://linuxunplugged.com/guests/martinwimpress") == "wimpy"


def test_unmatched_guests_urls(config_data):
# set global variable
scraper.config = config_data

# Selfhosted
assert get_username_from_url("https://selfhosted.show/guests/jscar") == "jscar"
assert get_username_from_url("https://selfhosted.show/guests/drewofdoom") == "drew-devore"

# Linux Unplugged
assert get_username_from_url("https://linuxunplugged.com/guests/christianschaller") == "christianschaller"