Exemplo n.º 1
0
 def test_title_not_empty(self):
     dataset = self.get_dataset()
     dataset["title"] = ""
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'USDA-DM-002: Missing Required Fields')
     errors = ["The 'title' field is present but empty. (1 locations)"]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 2
0
 def test_theme_is_array(self):
     dataset = self.get_dataset()
     dataset["theme"] = ""
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value (Optional Fields)'
     )
     errors = ["The field 'theme' must be an array. (1 locations)"]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 3
0
 def test_publisher_has_name(self):
     dataset = self.get_dataset()
     dataset["publisher"] = {}
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Missing Required Fields'
     )
     errors = ["The 'name' field is missing. (1 locations)"]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 4
0
 def test_modified_not_empty(self):
     dataset = self.get_dataset()
     dataset["modified"] = ""
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Missing Required Fields'
     )
     errors = ["The 'modified' field is present but empty. (1 locations)"]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 5
0
 def test_programCode_not_empty(self):
     dataset = self.get_dataset()
     dataset["programCode"] = []
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Missing Required Fields'
     )
     errors = ["The 'programCode' field is an empty array. (1 locations)"]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 6
0
 def test_title_not_too_short(self):
     dataset = self.get_dataset()
     dataset["title"] = "D"
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get('USDA-DM-002: Invalid Field Value')
     errors = [
         'The \'title\' field is very short (min. 2): "D" (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 7
0
 def test_issued_is_valid(self):
     dataset = self.get_dataset()
     dataset["issued"] = ""
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value (Optional Fields)'
     )
     errors = ["The field 'issued' is not in a valid format. (1 locations)"]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 8
0
 def test_bureu_code_is_string(self):
     dataset = self.get_dataset()
     dataset["bureauCode"] = [2]
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = ['Each bureauCode must be a string (1 locations)']
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 9
0
 def test_distribution_required_field_mediaType(self):
     dataset = self.get_dataset()
     dataset["distribution"] = [{
         "downloadURL": "",
     }]
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014 distribution 1: Missing Required Fields'
     )
     errors = ["The 'mediaType' field is missing. (1 locations)"]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 10
0
 def test_dataQuality_is_bool(self):
     dataset = self.get_dataset()
     dataset["dataQuality"] = ""
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value (Optional Fields)'
     )
     errors = [
         'The field \'dataQuality\' must be true or false, as a JSON boolean literal (not the string "true" or "false"). (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 11
0
 def test_email_valid(self):
     dataset = self.get_dataset()
     dataset["contactPoint"]["hasEmail"] = "mailto:@example.com"
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = [
         'The email address "@example.com" is not a valid email address. (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 12
0
 def test_describedByType_is_valid(self):
     dataset = self.get_dataset()
     dataset["describedByType"] = "l"
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value'
     )
     errors = [
         'The describedByType "l" is invalid. It must be in IANA MIME format. (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 13
0
 def test_programCode_format(self):
     dataset = self.get_dataset()
     dataset["programCode"] = ""
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = [
         "The 'programCode' field must be a array but it has a different datatype (string). (1 locations)"
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 14
0
 def test_modified_format(self):
     dataset = self.get_dataset()
     dataset["modified"] = "dfsfsdf"
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = [
         'The field "modified" is not in valid format: "dfsfsdf" (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 15
0
 def test_keyword_is_array(self):
     dataset = self.get_dataset()
     dataset["keyword"] = ""
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Update Your File!'
     )
     errors = [
         'The keyword field used to be a string but now it must be an array. (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 16
0
 def test_accrualPeriodicity_is_valid(self):
     dataset = self.get_dataset()
     dataset["accrualPeriodicity"] = "R/P10"
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value (Optional Fields)'
     )
     errors = [
         "The field 'accrualPeriodicity' had an invalid value. (1 locations)"
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 17
0
 def test_programCode_item_format(self):
     dataset = self.get_dataset()
     dataset["programCode"] = ["005:9"]
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value (Optional Fields)'
     )
     errors = [
         'One of programCodes is not in valid format (ex. 018:001): "005:9" (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 18
0
 def test_isPartOf_is_valid(self):
     dataset = self.get_dataset()
     dataset["isPartOf"] = 2
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = [
         "The 'isPartOf' field must be a string but it has a different datatype (<class 'int'>). (1 locations)"
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 19
0
 def test_publisher_is_dictionary(self):
     dataset = self.get_dataset()
     dataset["publisher"] = ""
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = [
         "The 'publisher' field must be a <class 'dict'> but it has a different datatype (string). (1 locations)"
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 20
0
 def test_temporal_is_string(self):
     dataset = self.get_dataset()
     dataset["temporal"] = []
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value (Optional Fields)'
     )
     errors = [
         "The field 'temporal' must be a string value if specified. (1 locations)"
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 21
0
 def test_bureu_code_known(self):
     dataset = self.get_dataset()
     dataset["bureauCode"] = ['005:48']
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = [
         'The bureau code "005:48" was not found in our list https://project-open-data.cio.gov/data/omb_bureau_codes.csv (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 22
0
 def test_theme_items_are_strings(self):
     dataset = self.get_dataset()
     dataset["theme"] = [2]
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value (Optional Fields)'
     )
     errors = [
         'Each value in the theme array must be a string (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 23
0
 def test_bureu_code_not_empty(self):
     dataset = self.get_dataset()
     dataset["bureauCode"] = [""]
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = [
         'The bureau code "" is invalid. Start with the agency code, then a colon, then the bureau code. (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 24
0
 def test_access_level_valid(self):
     dataset = self.get_dataset()
     dataset["accessLevel"] = "super-public"
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = [
         'The field \'accessLevel\' had an invalid value: "super-public" (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 25
0
 def test_PrimaryITInvestmentUII_is_valid(self):
     dataset = self.get_dataset()
     dataset["PrimaryITInvestmentUII"] = ""
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value (Optional Fields)'
     )
     errors = [
         "The field 'PrimaryITInvestmentUII' must be a string in 023-000000001 format, if present. (1 locations)"
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 26
0
 def test_language_is_valid(self):
     dataset = self.get_dataset()
     dataset["language"] = ["a"]
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Field Value (Optional Fields)'
     )
     errors = [
         'The field \'language\' had an invalid language: "a" (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 27
0
 def test_keywords_are_strings(self):
     dataset = self.get_dataset()
     dataset["keyword"] = ["", 2]
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Invalid Required Field Value'
     )
     errors = [
         'A keyword in the keyword array was an empty string. (1 locations)',
         'Each keyword in the keyword array must be a string (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 28
0
 def test_contact_point_not_empty(self):
     dataset = self.get_dataset()
     dataset["contactPoint"] = {}
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014: Missing Required Fields'
     )
     errors = [
         "The 'fn' field is missing. (1 locations)",
         "The 'hasEmail' field is missing. (1 locations)"
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 29
0
 def test_distribution_mediaType(self):
     dataset = self.get_dataset()
     dataset["distribution"] = [{
         "downloadURL": "",
         "mediaType": "s",
     }]
     errors = validate_data_json(dataset)
     get_errors_with_key = errors[0].get(
         'Department of Agriculture Congressional Logs for Fiscal Year 2014 distribution 1: Invalid Field Value'
     )
     errors = [
         'The distribution mediaType "s" is invalid. It must be in IANA MIME format. (1 locations)'
     ]
     self.assertEqual(errors, get_errors_with_key)
Exemplo n.º 30
0
 def test_fields_missing(self):
     errors = validate_data_json({})
     get_errors_with_key = errors[0].get(': Missing Required Fields')
     self.assertIn("The 'accessLevel' field is missing.",
                   get_errors_with_key)
     self.assertIn("The 'bureauCode' field is missing.",
                   get_errors_with_key)
     self.assertIn("The 'contactPoint' field is missing.",
                   get_errors_with_key)
     self.assertIn("The 'description' field is missing.",
                   get_errors_with_key)
     self.assertIn("The 'identifier' field is missing.",
                   get_errors_with_key)
     self.assertIn("The 'keyword' field is missing.", get_errors_with_key)
     self.assertIn("The 'modified' field is missing.", get_errors_with_key)
     self.assertIn("The 'programCode' field is missing.",
                   get_errors_with_key)
     self.assertIn("The 'publisher' field is missing.", get_errors_with_key)
     self.assertIn("The 'title' field is missing.", get_errors_with_key)