Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1357] datastore:only accept limited date format conversions
only accept yyyymmdd, ddmmyyyy, mmddyyyy as valid date formats for conversions. change tests to be suit testing coding standards
- Loading branch information
Showing
6 changed files
with
311 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ckan.new_tests.helpers as helpers | ||
import ckan.new_tests.factories as factories | ||
|
||
|
||
def create_test_datastore_resource(field_name, field_type, record): | ||
package = factories.Package.create() | ||
resource = factories.Resource.create( | ||
package_id=package['id'], url_type='datastore') | ||
helpers.call_action( | ||
'datastore_create', | ||
resource_id=resource['id'], | ||
fields=[{'id': field_name, 'type': field_type}, ], | ||
records=[{field_name: record, }, ], | ||
) | ||
return resource['id'] | ||
|
||
def delete_test_datastore_resource(resource_id): | ||
helpers.call_action( | ||
'datastore_delete', | ||
resource_id=resource_id, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import unittest | ||
import ckan.lib.navl.dictization_functions as df | ||
import ckanext.datastore.logic.schema as schema | ||
|
||
|
||
class TestDateFormatValidator(unittest.TestCase): | ||
def test_is_valid_date_format(self): | ||
schema.is_date_format('yyyymmdd', {}) | ||
schema.is_date_format('ddmmYyyy', {}) | ||
schema.is_date_format('Mmddyyyy', {}) | ||
|
||
def test_is_invalid_date_format(self): | ||
self.assertRaises( | ||
df.Invalid, | ||
schema.is_date_format, | ||
'yyyy-mm-dd%%', | ||
{} | ||
) |
Oops, something went wrong.