-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check for error if conversation is the wrong type
- Loading branch information
Showing
1 changed file
with
20 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|