Skip to content

Commit

Permalink
check for error if conversation is the wrong type
Browse files Browse the repository at this point in the history
  • Loading branch information
bvreede committed Oct 31, 2023
1 parent edaadb7 commit 6269e55
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions tests/corpus/test_corpus.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
import pytest
from sktalk.corpus.corpus import Corpus
from contextlib import nullcontext as does_not_raise

class TestCorpus():

@pytest.mark.parametrize("conversations,metadata",
@pytest.mark.parametrize("conversations,metadata,error",
[
([], {"author": "Person",
"language": "french"}),
"language": "french"},
does_not_raise()),
(None, {"author": "Person",
"language": "french"}),
(None, {}),
([], {})
"language": "french"},
does_not_raise()),
(None, {}, does_not_raise()),
([], {}, does_not_raise()),
("Not A Conversation", {}, pytest.raises(TypeError))
])
def test_init(self, conversations, metadata):
corpus: Corpus = Corpus(conversations = conversations,
def test_init(self, conversations, metadata, error):
with error:
corpus: Corpus = Corpus(conversations = conversations,
**metadata)

# check that a corpus object is created
assert isinstance(corpus, Corpus)
# corpus object has metadata (can be empty, but should be created)
assert isinstance(corpus.metadata, dict)
# check that a corpus object is created
assert isinstance(corpus, Corpus)
# corpus object has metadata (can be empty, but should be created)
assert isinstance(corpus.metadata, dict)

# corpus object has or has not (zero, one, multiple) conversations
# assert corpus.conversations == conversations
assert isinstance(corpus.conversations, list)
assert conversations is None or corpus.conversations == conversations


# initialize a corpus with conversation object that is not a conversation should fail
# corpus object has or has not (zero, one, multiple) conversations
# assert corpus.conversations == conversations
assert isinstance(corpus.conversations, list)
assert conversations is None or corpus.conversations == conversations

0 comments on commit 6269e55

Please sign in to comment.