Skip to content

Commit

Permalink
test(corpus): add test for corpus setup, remove duplicate fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
hrishikeshrt committed Feb 16, 2022
1 parent a947c65 commit cb1b598
Showing 1 changed file with 10 additions and 49 deletions.
59 changes: 10 additions & 49 deletions tests/test_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 4,12 @@

import pytest

from pycdsl.corpus import SERVER_URL, CDSLCorpus
from pycdsl.lexicon import CDSLDict
from pycdsl.models import Entry

###############################################################################


@pytest.fixture(scope="package")
def cdsl_homepage():
"""Fixture for CDSL Homepage"""
import requests
return requests.get(SERVER_URL)


@pytest.fixture(scope="package")
def default_path(tmp_path_factory):
return tmp_path_factory.mktemp("cdsl_data")


@pytest.fixture(scope="package")
def default_corpus_options(default_path):
return {
'data_dir': default_path
}


@pytest.fixture(scope="package")
def default_corpus(default_corpus_options):
return CDSLCorpus(**default_corpus_options)


@pytest.fixture(scope="package")
def available_dicts(default_corpus):
return default_corpus.get_available_dicts()


@pytest.fixture(scope="package")
def installation_list():
return ["WIL"]


@pytest.fixture(scope="package")
def ready_corpus(default_corpus, installation_list):
default_corpus.setup(installation_list)
return default_corpus


@pytest.fixture(scope="package")
def installed_dicts(ready_corpus):
return ready_corpus.get_installed_dicts()


###############################################################################


def test_homepage_content(cdsl_homepage):
from bs4 import BeautifulSoup
soup = BeautifulSoup(cdsl_homepage.content.decode(), "html.parser")
Expand All @@ -75,6 26,16 @@ def test_available_dicts(available_dicts):
assert isinstance(cdsl_dict, CDSLDict)


def test_corpus_setup(default_corpus, installation_list):
assert default_corpus.setup(installation_list) is True


def test_corpus_setup_error_1(default_corpus, installation_list, caplog):
with pytest.raises(ValueError) as exc_info:
default_corpus.setup(installation_list[0])
assert exc_info.type is ValueError


def test_installed_dicts(installed_dicts, installation_list):
assert isinstance(installed_dicts, dict)
assert list(installed_dicts) == installation_list
Expand Down

0 comments on commit cb1b598

Please sign in to comment.