1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-13 04:02:29 +00:00
senpy/tests/plugins_test/__init__.py
J. Fernando Sánchez b8993f7d64 Added shelve mixin
2015-11-05 18:50:37 +01:00

42 lines
1.1 KiB
Python

import os
import logging
import shelve
try:
import unittest.mock as mock
except ImportError:
import mock
import json
import os
from unittest import TestCase
from senpy.models import Response, Entry
from senpy.plugins import SenpyPlugin, ShelfMixin
class ModelsTest(TestCase):
# def test_shelf(self):
# class ShelfTest(ShelfMixin):
# pass
# a = ShelfTest()
# print(type(a.sh))
# assert(False)
def test_shelf(self):
class ShelfTest(ShelfMixin, SenpyPlugin):
pass
a = ShelfTest({'name': 'shelve', 'version': 'test'})
print(type(a.sh))
a.context = "ohno"
del a.context
print(a)
a.sh['classifier'] = {'name': 'ohno'}
assert a.name == 'shelve'
assert isinstance(a.sh, shelve.Shelf)
a.close()
b = ShelfTest({'name': 'shelve', 'version': 'test'})
assert b.name == 'shelve'
assert b.sh['classifier']
assert b.sh['classifier']['name'] == 'ohno'
assert isinstance(b.sh, shelve.Shelf)