Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
orlnub123 committed Jul 25, 2018
1 parent ace9e54 commit acbf0f3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 34 deletions.
28 changes: 11 additions & 17 deletions tests/async_tests/test_cleverbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,15 @@ def test_cleverbot_save_named(self, cb_named):
cb_named.save(f)
assert f.getvalue()

def test_cleverbot_load_nameless(self, cb, cb_nameless):
def test_cleverbot_load_data(self, cb):
with io.BytesIO() as f:
cb_nameless.save(f)
cb.save(f)
with io.BytesIO(f.getvalue()) as f:
cb.load(f)
for convo1, convo2 in zip(cb.conversations, cb_nameless.conversations):
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
assert getattr(convo1, item) == getattr(convo2, item)
cb2 = cleverbot.Cleverbot(None)
cb2.load(f)
assert cb2.data == cb.data

def test_cleverbot_load_named(self, cb, cb_named):
def test_cleverbot_load_conversations(self, cb, cb_named):
convos = cb_named.conversations
with io.BytesIO() as f:
cb_named.save(f)
Expand All @@ -362,27 +361,22 @@ def test_cleverbot_load_named(self, cb, cb_named):
assert getattr(convo1, item) == getattr(convo2, item)

@pytest.mark.asyncio
def test_load_nameless(self, cb_nameless):
def test_load_data(self, cb):
with io.BytesIO() as f:
cb_nameless.save(f)
cb.save(f)
with io.BytesIO(f.getvalue()) as f:
cb = cleverbot.load(f)
cb2 = cleverbot.load(f)
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
assert getattr(cb, item) == getattr(cb_nameless, item)
for convo1, convo2 in zip(cb.conversations, cb_nameless.conversations):
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
assert getattr(convo1, item) == getattr(convo2, item)
assert getattr(cb2, item) == getattr(cb, item)
yield from cb.close()

@pytest.mark.asyncio
def test_load_named(self, cb_named):
def test_load_conversations(self, cb_named):
convos = cb_named.conversations
with io.BytesIO() as f:
cb_named.save(f)
with io.BytesIO(f.getvalue()) as f:
cb = cleverbot.load(f)
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
assert getattr(cb, item) == getattr(cb_named, item)
for name, convo1 in cb.conversations.items():
convo2 = convos[name]
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
Expand Down
28 changes: 11 additions & 17 deletions tests/test_cleverbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,15 @@ def test_cleverbot_save_named(self, cb_named):
cb_named.save(f)
assert f.getvalue()

def test_cleverbot_load_nameless(self, cb, cb_nameless):
def test_cleverbot_load_data(self, cb):
with io.BytesIO() as f:
cb_nameless.save(f)
cb.save(f)
with io.BytesIO(f.getvalue()) as f:
cb.load(f)
for convo1, convo2 in zip(cb.conversations, cb_nameless.conversations):
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
assert getattr(convo1, item) == getattr(convo2, item)
cb2 = cleverbot.Cleverbot(None)
cb2.load(f)
assert cb2.data == cb.data

def test_cleverbot_load_named(self, cb, cb_named):
def test_cleverbot_load_conversations(self, cb, cb_named):
convos = cb_named.conversations
with io.BytesIO() as f:
cb_named.save(f)
Expand All @@ -339,25 +338,20 @@ def test_cleverbot_load_named(self, cb, cb_named):
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
assert getattr(convo1, item) == getattr(convo2, item)

def test_load_nameless(self, cb_nameless):
def test_load_data(self, cb):
with io.BytesIO() as f:
cb_nameless.save(f)
cb.save(f)
with io.BytesIO(f.getvalue()) as f:
cb = cleverbot.load(f)
cb2 = cleverbot.load(f)
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
assert getattr(cb, item) == getattr(cb_nameless, item)
for convo1, convo2 in zip(cb.conversations, cb_nameless.conversations):
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
assert getattr(convo1, item) == getattr(convo2, item)
assert getattr(cb2, item) == getattr(cb, item)

def test_load_named(self, cb_named):
def test_load_conversations(self, cb_named):
convos = cb_named.conversations
with io.BytesIO() as f:
cb_named.save(f)
with io.BytesIO(f.getvalue()) as f:
cb = cleverbot.load(f)
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
assert getattr(cb, item) == getattr(cb_named, item)
for name, convo1 in cb.conversations.items():
convo2 = convos[name]
for item in ('key', 'cs', 'timeout', 'tweak1', 'tweak2', 'tweak3'):
Expand Down

0 comments on commit acbf0f3

Please sign in to comment.