예제 #1
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

import unittest
import json

import plugins
from mocks.storage import TestingKeyValueStorage
from mocks.request import Request, Controller, PluginApi
from mocks import mplugins
from plugins.abstract.user_items import FavoriteItem
from plugins.default_user_items import UserItems

plugins.inject_plugin(plugins.runtime.DB, TestingKeyValueStorage({}))
plugins.inject_plugin(plugins.runtime.AUTH, mplugins.MockAuth(0))
plugins.inject_plugin(plugins.runtime.USER_ITEMS, mplugins.MockUserItems())
from plugins.default_user_items import import_legacy_record, set_favorite_item, unset_favorite_item


def create_corpus_obj(name='korpus syn 2010'):
    return FavoriteItem(
        dict(name=name, corpora=[dict(id='syn2010', name='Korpus SYN2010')]))


class TestActions(unittest.TestCase):
    def test_import_legacy_record(self):
        legacy_rec = dict(id='foobar:1',
                          corpus_id='foobar',
                          name='The Foobar',
예제 #2
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

import unittest
import json

import plugins
from mocks.storage import TestingKeyValueStorage
from mocks.request import Request, Controller, PluginApi
from mocks import mplugins
from plugins.abstract.user_items import FavoriteItem
from plugins.default_user_items import UserItems


plugins.inject_plugin(plugins.runtime.DB, TestingKeyValueStorage({}))
plugins.inject_plugin(plugins.runtime.AUTH, mplugins.MockAuth(0))
plugins.inject_plugin(plugins.runtime.USER_ITEMS, mplugins.MockUserItems())
from plugins.default_user_items import import_legacy_record, set_favorite_item, unset_favorite_item


def create_corpus_obj(name='korpus syn 2010'):
    return FavoriteItem(dict(name=name, corpora=[dict(id='syn2010', name='Korpus SYN2010')]))


class TestActions(unittest.TestCase):

    def test_import_legacy_record(self):
        legacy_rec = dict(
            id='foobar:1',
            corpus_id='foobar',
예제 #3
0
# dated June, 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

import unittest


import plugins
from mocks.storage import TestingKeyValueStorage
from plugins.abstract.user_items import CorpusItem, SubcorpusItem, AlignedCorporaItem
import json

plugins.inject_plugin('db', TestingKeyValueStorage({}))
plugins.inject_plugin('auth', object())
from plugins.default_user_items import create_instance
from plugins.default_user_items import ItemEncoder, import_from_json


def create_corpus_obj(name='korpus syn 2010', corpus_id='public/syn2010', canonical_id='syn2010'):
    c = CorpusItem(name=name)
    c.corpus_id = corpus_id
    c.canonical_id = canonical_id
    return c


class TestCommon(unittest.TestCase):
    def setUp(self):
        plugins.get('db').reset()
예제 #4
0
# as published by the Free Software Foundation; version 2
# dated June, 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

import unittest

import plugins
from mocks.storage import TestingKeyValueStorage
from plugins.abstract.user_items import CorpusItem, SubcorpusItem, AlignedCorporaItem
import json

plugins.inject_plugin('db', TestingKeyValueStorage({}))
plugins.inject_plugin('auth', object())
from plugins.default_user_items import create_instance
from plugins.default_user_items import ItemEncoder, import_from_json


def create_corpus_obj(name='korpus syn 2010',
                      corpus_id='public/syn2010',
                      canonical_id='syn2010'):
    c = CorpusItem(name=name)
    c.corpus_id = corpus_id
    c.canonical_id = canonical_id
    return c


class TestCommon(unittest.TestCase):