Example #1
0
from couchexport.models import Format
from django.test import SimpleTestCase, TestCase
from StringIO import StringIO

from corehq.apps.domain.shortcuts import create_domain
from corehq.apps.fixtures.exceptions import FixtureUploadError
from corehq.apps.fixtures.models import FixtureDataItem
from corehq.apps.fixtures.upload import validate_fixture_file_format
from corehq.apps.fixtures.upload.failure_messages import FAILURE_MESSAGES
from corehq.apps.fixtures.upload.run_upload import _run_fixture_upload
from corehq.apps.fixtures.upload.workbook import get_workbook
from corehq.util.test_utils import make_make_path
from corehq.util.test_utils import generate_cases


_make_path = make_make_path(__file__)


validation_test_cases = [
    ('duplicate_tag', [
        u"Lookup-tables should have unique 'table_id'. "
        u"There are two rows with table_id 'things' in 'types' sheet.",

    ]),
    ('multiple_errors', [
        u"Excel-sheet 'level_1' does not contain the column "
        u"'field: fun_fact' as specified in its 'types' definition",
        u"Excel-sheet 'level_1' does not contain the column "
        u"'field: other' as specified in its 'types' definition",
        u"Excel-sheet 'level_2' does not contain the column "
        u"'field: other' as specified in its 'types' definition",
Example #2
0
from collections import namedtuple
from django.test import SimpleTestCase
from corehq.apps.fixtures.exceptions import FixtureUploadError
from corehq.apps.fixtures.upload import validate_fixture_file_format
from corehq.apps.fixtures.upload.failure_messages import FAILURE_MESSAGES
from corehq.util.test_utils import make_make_path


_make_path = make_make_path(__file__)


UploadTestConfig = namedtuple('UploadTestConfig', ['upload_file', 'error_messages'])


def _upload_test(name, error_messages):
    config = UploadTestConfig(_make_path('test_upload', '{}.xlsx'.format(name)),
                              error_messages)

    def inner(self):
        self._test(config)

    inner.func_name = 'test_{}'.format(name)

    return inner


class TestFixtureUpload(SimpleTestCase):
    maxDiff = None

    def _test(self, config):
        if config.error_messages: