<commit_before>import nose.tools
import os

import ckan.tests.helpers as helpers
import ckanext.mapactionimporter.tests.helpers as custom_helpers


class TestCreateDatasetFromZip(custom_helpers.FunctionalTestBaseClass):

    def test_it_allows_uploading_a_zipfile(self):
        dataset = helpers.call_action(
            'create_dataset_from_mapaction_zip',
            upload=_UploadFile(custom_helpers.get_test_file()))

        nose.tools.assert_equal(
            dataset['title'],
            'Central African Republic:  Example Map- Reference (as of 3 Feb 2099)')

        # Expect the JPEG And PDF referenced in the XML Metadata

        dataset = helpers.call_action('package_show', id=dataset['id'])

        resources = dataset['resources']

        import pdb; pdb.set_trace()

        nose.tools.assert_true(len(resources) == 2)
        nose.tools.assert_equal(resources[0]['url_type'], 'upload')
        #nose.tools.assert_true(resources[0]['name'] in resources[0]['url'])


class _UploadFile(object):
    '''Mock the parts from cgi.FileStorage we use.'''
    def __init__(self, fp):
        self.file = fp<commit_msg>Removed debug and commented out code<commit_after>import nose.tools
import os

import ckan.tests.helpers as helpers
import ckanext.mapactionimporter.tests.helpers as custom_helpers


class TestCreateDatasetFromZip(custom_helpers.FunctionalTestBaseClass):

    def test_it_allows_uploading_a_zipfile(self):
        dataset = helpers.call_action(
            'create_dataset_from_mapaction_zip',
            upload=_UploadFile(custom_helpers.get_test_file()))

        nose.tools.assert_equal(
            dataset['title'],
            'Central African Republic:  Example Map- Reference (as of 3 Feb 2099)')

        # Expect the JPEG And PDF referenced in the XML Metadata

        dataset = helpers.call_action('package_show', id=dataset['id'])

        resources = dataset['resources']

        nose.tools.assert_true(len(resources) == 2)
        nose.tools.assert_equal(resources[0]['url_type'], 'upload')


class _UploadFile(object):
    '''Mock the parts from cgi.FileStorage we use.'''
    def __init__(self, fp):
        self.file = fp
{'fraction_non_alphanumeric': 0.10170271514035895, 'fraction_numerical': 0.007363092498849517, 'mean_word_length': 3.4732510288065845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '12666', 'n_tokens_mistral': 652, 'n_tokens_neox': 631, 'n_words': 142}