Exemple #1
0
    def test_it_allows_uploading_a_zipfile(self):
        dataset = helpers.call_action('create_dataset_from_mapaction_zip',
                                      upload=_UploadFile(
                                          custom_helpers.get_test_zip()))

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

        nose.tools.assert_equal(dataset['name'], '189-ma001-aptivate-example')

        # Expect the JPEG And PDF referenced in the XML Metadata
        dataset = helpers.call_action('package_show', id=dataset['id'])
        resources = dataset['resources']
        extras = dataset['extras']

        nose.tools.assert_true(len(resources) == 2)
        nose.tools.assert_true(len(extras) > 0)

        sorted_resources = sorted(resources, key=lambda k: k['format'])

        self._check_uploaded_resource(sorted_resources[0], 'JPEG',
                                      'MA001_Aptivate_Example-300dpi.jpeg',
                                      'ma001aptivateexample-300dpi.jpeg')
        self._check_uploaded_resource(sorted_resources[1], 'PDF',
                                      'MA001_Aptivate_Example-300dpi.pdf',
                                      'ma001aptivateexample-300dpi.pdf')
    def test_it_allows_uploading_a_zipfile(self):
        dataset = helpers.call_action(
            "create_dataset_from_mapaction_zip", upload=_UploadFile(custom_helpers.get_test_zip())
        )

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

        nose.tools.assert_equal(dataset["name"], "189-ma001-aptivate-example")

        # Expect the JPEG And PDF referenced in the XML Metadata
        dataset = helpers.call_action("package_show", id=dataset["id"])
        resources = dataset["resources"]
        extras = dataset["extras"]

        nose.tools.assert_true(len(resources) == 2)
        nose.tools.assert_true(len(extras) > 0)

        sorted_resources = sorted(resources, key=lambda k: k["format"])

        self._check_uploaded_resource(
            sorted_resources[0], "JPEG", "MA001_Aptivate_Example-300dpi.jpeg", "ma001aptivateexample-300dpi.jpeg"
        )
        self._check_uploaded_resource(
            sorted_resources[1], "PDF", "MA001_Aptivate_Example-300dpi.pdf", "ma001aptivateexample-300dpi.pdf"
        )
    def test_import_zipfile(self):
        user = factories.User()
        organization = factories.Organization(user=user)

        env = {'REMOTE_USER': user['name'].encode('ascii')}
        url = toolkit.url_for('import_mapactionzip')

        params = {
            'owner_org': organization['id'],
        }

        response = self.app.post(
            url,
            params,
            extra_environ=env,
            upload_files=[(
                'upload',
                custom_helpers.get_test_zip().name,
            )],
        )

        # Should redirect to dataset's page
        assert_equals(response.status_int, 302)

        slug = '189-ma001-aptivate-example'
        assert_regexp_matches(
            response.headers['Location'],
            '/dataset/edit/%s' % slug)

        # Should create the dataset
        dataset = helpers.call_action('package_show', id=slug)
        assert_equals(dataset['name'], slug)
        assert_equals(dataset['private'], True)
    def test_import_zipfile(self):
        user = factories.User()
        organization = factories.Organization(user=user)

        env = {'REMOTE_USER': user['name'].encode('ascii')}
        url = toolkit.url_for('import_mapactionzip')

        params = {
            'owner_org': organization['id'],
        }

        response = self.app.post(
            url,
            params,
            extra_environ=env,
            upload_files=[(
                'upload',
                custom_helpers.get_test_zip().name,
            )],
        )

        # Should redirect to dataset's page
        assert_equals(response.status_int, 302)

        slug = '189-ma001-aptivate-example'
        assert_regexp_matches(response.headers['Location'],
                              '/dataset/edit/%s' % slug)

        # Should create the dataset
        dataset = helpers.call_action('package_show', id=slug)
        assert_equals(dataset['name'], slug)
        assert_equals(dataset['private'], True)
Exemple #5
0
    def test_dataset_notes_set_to_xml_summary(self):
        dataset = helpers.call_action('create_dataset_from_mapaction_zip',
                                      upload=_UploadFile(
                                          custom_helpers.get_test_zip()))

        summary = (
            "Example reference map of the Central African Republic.  This "
            "is an example map only and for testing use only")
        nose.tools.assert_equal(dataset['notes'], summary)
Exemple #6
0
 def test_dataset_private_when_organization_specified(self):
     user = factories.User()
     organization = factories.Organization(user=user)
     dataset = helpers.call_action('create_dataset_from_mapaction_zip',
                                   context={'user': user['id']},
                                   upload=_UploadFile(
                                       custom_helpers.get_test_zip()),
                                   owner_org=organization['id'])
     nose.tools.assert_true(dataset['private'])
    def test_dataset_notes_set_to_xml_summary(self):
        dataset = helpers.call_action(
            "create_dataset_from_mapaction_zip", upload=_UploadFile(custom_helpers.get_test_zip())
        )

        summary = (
            "Example reference map of the Central African Republic.  This "
            "is an example map only and for testing use only"
        )
        nose.tools.assert_equal(dataset["notes"], summary)
 def test_dataset_private_when_organization_specified(self):
     user = factories.User()
     organization = factories.Organization(user=user)
     dataset = helpers.call_action(
         "create_dataset_from_mapaction_zip",
         context={"user": user["id"]},
         upload=_UploadFile(custom_helpers.get_test_zip()),
         owner_org=organization["id"],
     )
     nose.tools.assert_true(dataset["private"])
Exemple #9
0
 def test_dataset_public_when_no_organization_specified(self):
     dataset = helpers.call_action('create_dataset_from_mapaction_zip',
                                   upload=_UploadFile(
                                       custom_helpers.get_test_zip()))
     nose.tools.assert_false(dataset['private'])
 def test_dataset_public_when_no_organization_specified(self):
     dataset = helpers.call_action(
         "create_dataset_from_mapaction_zip", upload=_UploadFile(custom_helpers.get_test_zip())
     )
     nose.tools.assert_false(dataset["private"])