• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OCHA-DAP / hdx-ckan / #5288

24 Apr 2024 07:00AM UTC coverage: 71.904%. Remained the same
#5288

push

coveralls-python

danmihaila
HDX-9749 request new org test + review validation schema

8 of 12 new or added lines in 2 files covered. (66.67%)

1 existing line in 1 file now uncovered.

11734 of 16319 relevant lines covered (71.9%)

0.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.94
/ckanext-hdx_org_group/ckanext/hdx_org_group/controller_logic/organization_request_logic.py
1
import logging
1✔
2

3
import ckan.lib.navl.dictization_functions as dictization_functions
1✔
4
import ckan.logic as logic
1✔
5
import ckan.plugins.toolkit as tk
1✔
6
from ckan.types import Context
1✔
7
from ckan.logic.schema import validator_args
1✔
8
from ckan.lib.navl.dictization_functions import validate
1✔
9

10
get_action = tk.get_action
1✔
11
check_access = tk.check_access
1✔
12
config = tk.config
1✔
13
h = tk.h
1✔
14
NotAuthorized = tk.NotAuthorized
1✔
15
unicode_safe = tk.get_validator('unicode_safe')
1✔
16
log = logging.getLogger(__name__)
1✔
17

18

19
@validator_args
1✔
20
def request_new_organization_schema(not_empty, ignore_missing, hdx_url_validator):
1✔
21
    schema = {
1✔
22
        'name': [not_empty, unicode_safe],
23
        'description': [not_empty, unicode_safe],
24
        'website': [ignore_missing, unicode_safe, hdx_url_validator],
25
        'role': [not_empty, unicode_safe],
26
        'data_type': [not_empty, unicode_safe],
27
        'data_already_available': [not_empty, unicode_safe],
28
        'data_already_available_link': [ignore_missing, unicode_safe, hdx_url_validator],
29
    }
30
    return schema
1✔
31

32

33
class OrgRequestLogic(object):
1✔
34
    def __init__(self, context: Context, request):
1✔
35
        self.request = request
1✔
36
        self.context = context
1✔
37
        self.form = request.form
1✔
38
        self.schema = request_new_organization_schema()
1✔
39

40
    def read(self):
1✔
41
        data_dict = logic.clean_dict(
1✔
42
            dictization_functions.unflatten(
43
                logic.tuplize_dict(logic.parse_params(self.form))))
44
        return data_dict
1✔
45

46
    def validate(self, data_dict):
1✔
47
        try:
1✔
48
            validated_response = validate(data_dict, self.schema, self.context)
1✔
NEW
49
        except Exception as ex:
×
NEW
50
            log.error(ex)
×
51
        return validated_response
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc