Esempio n. 1
0
 def test_clean(self):
     """Check that validation passes"""
     self.mock_sql.return_value = {"rows": [{
         "name": "",
         "pcode": "",
         "parent": "",
     }]}
     form = forms.CartoDBTableForm(self.data)
     self.assertTrue(self._test_clean(form))
     self.assertEqual(form.errors.as_data(), {})
Esempio n. 2
0
 def test_no_connection(self):
     """Check that validation fails when SQLClient request fails"""
     self.mock_sql.side_effect = CartoException
     form = forms.CartoDBTableForm(self.data)
     self.assertFalse(self._test_clean(form))
     errors = form.errors.as_data()
     self.assertEqual(len(errors["__all__"]), 1)
     self.assertEqual(
         errors["__all__"][0].message,
         "Couldn't connect to CartoDB table: test"
     )
Esempio n. 3
0
 def test_no_parent_code_col(self):
     """Check that validation fails when `parent_code_col` is missing"""
     self.mock_sql.return_value = {"rows": [{
         "name": "",
         "pcode": "",
     }]}
     form = forms.CartoDBTableForm(self.data)
     self.assertFalse(self._test_clean(form))
     errors = form.errors.as_data()
     self.assertEqual(len(errors["__all__"]), 1)
     self.assertEqual(
         errors["__all__"][0].message,
         "The Parent Code column (parent) is not in table: test"
     )