Beispiel #1
0
 def test_create__missing_required_fields(self, mock_get_loc_info):
     mock_get_loc_info.return_value = (geos.Point(1, -1), "somewhere")
     info = self._make_geojson(coords=[1.0, -1.0], type="test-schema")
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(
         e.exception.errors, {"description": [u"This field is required."], "title": [u"This field is required."]}
     )
Beispiel #2
0
 def test_create__missing_required_fields(self, mock_get_loc_info):
     mock_get_loc_info.return_value = (geos.Point(1, -1), 'somewhere')
     info = self._make_geojson(coords=[1.0, -1.0], type='test-schema')
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(e.exception.errors, {
         'title': [u'This field is required.'],
     })
Beispiel #3
0
 def test_create__missing_required_fields(self, mock_get_loc_info):
     mock_get_loc_info.return_value = (geos.Point(1,-1), 'somewhere')
     info = self._make_geojson(coords=[1.0, -1.0], type='test-schema')
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(e.exception.errors,
                      {'title': [u'This field is required.'],
                       })
Beispiel #4
0
 def test_create__bad_dates(self):
     info = self._make_geojson(coords=[1.0, -1.0], type='test-schema',
                               name='hello', title='hello title',
                               description='hello descr', url='http://foo.com',
                               item_date='ouch', location_name='here',
                               )
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(e.exception.errors,
                      {'item_date': [u'Enter a valid date.']})
Beispiel #5
0
 def test_create__bad_dates(self):
     info = self._make_geojson(coords=[1.0, -1.0], type='test-schema',
                               name='hello', title='hello title',
                               description='hello descr', url='http://foo.com',
                               item_date='ouch', location_name='here',
                               )
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(e.exception.errors,
                      {'item_date': [u'Enter a valid date.']})
Beispiel #6
0
 def test_create_with_new_lookups(self, mock_get_loc_info):
     mock_get_loc_info.return_value = (geos.Point(1,-1), 'somewhere')
     info = self._make_geojson(coords=[1.0, -1.0],
                               lookup=['Lookup 7702 Name', 'Lookup 7703 Name'],
                               type='test-schema',
                               title='I have lookups too', description='yes i do',
                               url='http://foo.com',
                               )
     views._item_create(info)
     item = NewsItem.objects.get(title='I have lookups too')
     self.assertEqual(item.attributes['lookup'], u'7702,7703')
Beispiel #7
0
 def test_create_with_new_lookups(self, mock_get_loc_info):
     mock_get_loc_info.return_value = (geos.Point(1,-1), 'somewhere')
     info = self._make_geojson(coords=[1.0, -1.0],
                               lookup=['Lookup 7702 Name', 'Lookup 7703 Name'],
                               type='test-schema',
                               title='I have lookups too', description='yes i do',
                               url='http://foo.com',
                               )
     views._item_create(info)
     item = NewsItem.objects.get(title='I have lookups too')
     self.assertEqual(item.attributes['lookup'], u'7702,7703')
Beispiel #8
0
 def test_create_with_new_lookups(self, mock_get_loc_info):
     mock_get_loc_info.return_value = (geos.Point(1, -1), "somewhere")
     info = self._make_geojson(
         coords=[1.0, -1.0],
         lookup=["Lookup 7702 Name", "Lookup 7703 Name"],
         type="test-schema",
         title="I have lookups too",
         description="yes i do",
         url="http://foo.com",
     )
     views._item_create(info)
     item = NewsItem.objects.get(title="I have lookups too")
     self.assertEqual(item.attributes["lookup"], u"7702,7703")
Beispiel #9
0
 def test_create__bad_dates(self):
     info = self._make_geojson(
         coords=[1.0, -1.0],
         type="test-schema",
         name="hello",
         title="hello title",
         description="hello descr",
         url="http://foo.com",
         item_date="ouch",
         location_name="here",
     )
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(e.exception.errors, {"item_date": [u"Enter a valid date."]})
Beispiel #10
0
 def test_create__no_geojson(self):
     info = {"type": "ouchie"}
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(e.exception.errors, {"type": "not a valid GeoJSON Feature"})
Beispiel #11
0
 def test_create__no_schema(self):
     info = self._make_geojson(coords=[1.0, 2.0])
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(e.exception.errors, {"type": "schema None does not exist"})
Beispiel #12
0
 def test_create__no_geojson(self):
     info = {'type': 'ouchie'}
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(e.exception.errors,
                      {'type': 'not a valid GeoJSON Feature'})
Beispiel #13
0
 def test_create__no_schema(self):
     info = self._make_geojson(coords=[1.0, 2.0])
     with self.assertRaises(views.InvalidNewsItem) as e:
         views._item_create(info)
     self.assertEqual(e.exception.errors,
                      {'type': 'schema None does not exist'})