示例#1
0
    def testValidDSPL(self):
        """A simple end-to-end test of the valid XML case."""
        dspl_validator = dspl_validation.DSPLDatasetValidator(self.dataset)
        dspl_validator.RunValidation()

        all_issues = dspl_validator.GetIssues()
        self.assertEqual(len(all_issues), 0)
示例#2
0
    def _SingleIssueTestHelper(self, check_stages, expected_scope,
                               expected_type, expected_base_entity_id):
        """Run the validator and check the (single) issue produced."""
        dspl_validator = dspl_validation.DSPLDatasetValidator(self.dataset)

        if 'concepts' in check_stages:
            dspl_validator.CheckConcepts()

        if 'slices' in check_stages:
            dspl_validator.CheckSlices()

        if 'tables' in check_stages:
            dspl_validator.CheckTables()

        if 'data' in check_stages:
            dspl_validator.CheckData()

        all_issues = dspl_validator.GetIssues()

        self.assertEqual(len(all_issues), 1)

        issue = all_issues[0]

        self.assertEqual(issue.issue_scope, expected_scope)
        self.assertEqual(issue.issue_type, expected_type)
        self.assertEqual(issue.base_entity_id, expected_base_entity_id)

        if issue.base_entity_id:
            self.assertTrue(issue.base_entity_id in issue.message)
示例#3
0
    def testBlankMetricValues(self):
        self.dataset.GetTable('countries_slice_table').table_data.append(
            ['US', '1966', ''])

        dspl_validator = dspl_validation.DSPLDatasetValidator(self.dataset)
        dspl_validator.CheckData()
        all_issues = dspl_validator.GetIssues()
        self.assertEqual(len(all_issues), 0)
示例#4
0
  def testResultsString(self):
    self.dataset.GetConcept('country').table_ref = ''
    self.dataset.GetSlice('countries_slice').table_ref = 'nonexistent_table'
    self.dataset.GetTable('countries_slice_table').columns[0].column_id = (
        'nonexistent_column')

    dspl_validator = dspl_validation.DSPLDatasetValidator(self.dataset)

    result = dspl_validator.RunValidation()
    self.assertEqual(len(result.split('\n')), 13)
示例#5
0
    def testTableColumnInvariance(self):
        """Test that checking is invariant to ordering of columns in CSVs."""
        # Re-sort table columns in decending order by ID
        for table in self.dataset.tables:
            table.columns.sort(key=lambda c: c.column_id, reverse=True)

        dspl_validator = dspl_validation.DSPLDatasetValidator(self.dataset)
        dspl_validator.RunValidation()

        all_issues = dspl_validator.GetIssues()
        self.assertEqual(len(all_issues), 0)
示例#6
0
    def testPartialDataCheck(self):
        self.dataset.GetTable('countries_slice_table').table_data.append(
            ['AF', '1975', 'xxxx110188299'])
        self.dataset.GetTable('countries_table').table_data.append(
            ['AL', 'Albania', 'xxx41.153332', '20.168331'])

        dspl_validator = dspl_validation.DSPLDatasetValidator(
            self.dataset, full_data_check=False)
        dspl_validator.RunValidation()

        all_issues = dspl_validator.GetIssues()
        self.assertEqual(len(all_issues), 0)