Test updates
This commit is contained in:
parent
60ceeb0ddd
commit
6925344807
@ -279,7 +279,7 @@ class FileTest(unittest.TestCase):
|
|||||||
t.image.put(f)
|
t.image.put(f)
|
||||||
self.fail("Should have raised an invalidation error")
|
self.fail("Should have raised an invalidation error")
|
||||||
except ValidationError, e:
|
except ValidationError, e:
|
||||||
self.assertEquals("%s" % e, "Invalid image: cannot identify image file")
|
self.assertEqual("%s" % e, "Invalid image: cannot identify image file")
|
||||||
|
|
||||||
t = TestImage()
|
t = TestImage()
|
||||||
t.image.put(open(TEST_IMAGE_PATH, 'rb'))
|
t.image.put(open(TEST_IMAGE_PATH, 'rb'))
|
||||||
|
@ -422,11 +422,11 @@ class GeoQueriesTest(unittest.TestCase):
|
|||||||
|
|
||||||
Location(loc=[1,2]).save()
|
Location(loc=[1,2]).save()
|
||||||
loc = Location.objects.as_pymongo()[0]
|
loc = Location.objects.as_pymongo()[0]
|
||||||
self.assertEquals(loc["loc"], {"type": "Point", "coordinates": [1, 2]})
|
self.assertEqual(loc["loc"], {"type": "Point", "coordinates": [1, 2]})
|
||||||
|
|
||||||
Location.objects.update(set__loc=[2,1])
|
Location.objects.update(set__loc=[2,1])
|
||||||
loc = Location.objects.as_pymongo()[0]
|
loc = Location.objects.as_pymongo()[0]
|
||||||
self.assertEquals(loc["loc"], {"type": "Point", "coordinates": [2, 1]})
|
self.assertEqual(loc["loc"], {"type": "Point", "coordinates": [2, 1]})
|
||||||
|
|
||||||
def test_2dsphere_linestring_sets_correctly(self):
|
def test_2dsphere_linestring_sets_correctly(self):
|
||||||
class Location(Document):
|
class Location(Document):
|
||||||
@ -436,11 +436,11 @@ class GeoQueriesTest(unittest.TestCase):
|
|||||||
|
|
||||||
Location(line=[[1, 2], [2, 2]]).save()
|
Location(line=[[1, 2], [2, 2]]).save()
|
||||||
loc = Location.objects.as_pymongo()[0]
|
loc = Location.objects.as_pymongo()[0]
|
||||||
self.assertEquals(loc["line"], {"type": "LineString", "coordinates": [[1, 2], [2, 2]]})
|
self.assertEqual(loc["line"], {"type": "LineString", "coordinates": [[1, 2], [2, 2]]})
|
||||||
|
|
||||||
Location.objects.update(set__line=[[2, 1], [1, 2]])
|
Location.objects.update(set__line=[[2, 1], [1, 2]])
|
||||||
loc = Location.objects.as_pymongo()[0]
|
loc = Location.objects.as_pymongo()[0]
|
||||||
self.assertEquals(loc["line"], {"type": "LineString", "coordinates": [[2, 1], [1, 2]]})
|
self.assertEqual(loc["line"], {"type": "LineString", "coordinates": [[2, 1], [1, 2]]})
|
||||||
|
|
||||||
def test_geojson_PolygonField(self):
|
def test_geojson_PolygonField(self):
|
||||||
class Location(Document):
|
class Location(Document):
|
||||||
@ -450,11 +450,11 @@ class GeoQueriesTest(unittest.TestCase):
|
|||||||
|
|
||||||
Location(poly=[[[40, 5], [40, 6], [41, 6], [40, 5]]]).save()
|
Location(poly=[[[40, 5], [40, 6], [41, 6], [40, 5]]]).save()
|
||||||
loc = Location.objects.as_pymongo()[0]
|
loc = Location.objects.as_pymongo()[0]
|
||||||
self.assertEquals(loc["poly"], {"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]})
|
self.assertEqual(loc["poly"], {"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]})
|
||||||
|
|
||||||
Location.objects.update(set__poly=[[[40, 4], [40, 6], [41, 6], [40, 4]]])
|
Location.objects.update(set__poly=[[[40, 4], [40, 6], [41, 6], [40, 4]]])
|
||||||
loc = Location.objects.as_pymongo()[0]
|
loc = Location.objects.as_pymongo()[0]
|
||||||
self.assertEquals(loc["poly"], {"type": "Polygon", "coordinates": [[[40, 4], [40, 6], [41, 6], [40, 4]]]})
|
self.assertEqual(loc["poly"], {"type": "Polygon", "coordinates": [[[40, 4], [40, 6], [41, 6], [40, 4]]]})
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -2538,7 +2538,7 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
book = Book(title="The Stories", authors=[mark_twain, john_tolkien]).save()
|
book = Book(title="The Stories", authors=[mark_twain, john_tolkien]).save()
|
||||||
authors = Book.objects.distinct("authors")
|
authors = Book.objects.distinct("authors")
|
||||||
|
|
||||||
self.assertEquals(authors, [mark_twain, john_tolkien])
|
self.assertEqual(authors, [mark_twain, john_tolkien])
|
||||||
|
|
||||||
def test_custom_manager(self):
|
def test_custom_manager(self):
|
||||||
"""Ensure that custom QuerySetManager instances work as expected.
|
"""Ensure that custom QuerySetManager instances work as expected.
|
||||||
@ -3641,9 +3641,9 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
docs = Noddy.objects.no_cache()
|
docs = Noddy.objects.no_cache()
|
||||||
|
|
||||||
counter = len([1 for i in docs])
|
counter = len([1 for i in docs])
|
||||||
self.assertEquals(counter, 100)
|
self.assertEqual(counter, 100)
|
||||||
|
|
||||||
self.assertEquals(len(list(docs)), 100)
|
self.assertEqual(len(list(docs)), 100)
|
||||||
self.assertRaises(TypeError, lambda: len(docs))
|
self.assertRaises(TypeError, lambda: len(docs))
|
||||||
|
|
||||||
with query_counter() as q:
|
with query_counter() as q:
|
||||||
|
@ -172,30 +172,30 @@ class TransformTest(unittest.TestCase):
|
|||||||
loc = PointField()
|
loc = PointField()
|
||||||
|
|
||||||
update = transform.update(Location, set__loc=[1, 2])
|
update = transform.update(Location, set__loc=[1, 2])
|
||||||
self.assertEquals(update, {'$set': {'loc': {"type": "Point", "coordinates": [1,2]}}})
|
self.assertEqual(update, {'$set': {'loc': {"type": "Point", "coordinates": [1,2]}}})
|
||||||
|
|
||||||
update = transform.update(Location, set__loc={"type": "Point", "coordinates": [1,2]})
|
update = transform.update(Location, set__loc={"type": "Point", "coordinates": [1,2]})
|
||||||
self.assertEquals(update, {'$set': {'loc': {"type": "Point", "coordinates": [1,2]}}})
|
self.assertEqual(update, {'$set': {'loc': {"type": "Point", "coordinates": [1,2]}}})
|
||||||
|
|
||||||
def test_geojson_LineStringField(self):
|
def test_geojson_LineStringField(self):
|
||||||
class Location(Document):
|
class Location(Document):
|
||||||
line = LineStringField()
|
line = LineStringField()
|
||||||
|
|
||||||
update = transform.update(Location, set__line=[[1, 2], [2, 2]])
|
update = transform.update(Location, set__line=[[1, 2], [2, 2]])
|
||||||
self.assertEquals(update, {'$set': {'line': {"type": "LineString", "coordinates": [[1, 2], [2, 2]]}}})
|
self.assertEqual(update, {'$set': {'line': {"type": "LineString", "coordinates": [[1, 2], [2, 2]]}}})
|
||||||
|
|
||||||
update = transform.update(Location, set__line={"type": "LineString", "coordinates": [[1, 2], [2, 2]]})
|
update = transform.update(Location, set__line={"type": "LineString", "coordinates": [[1, 2], [2, 2]]})
|
||||||
self.assertEquals(update, {'$set': {'line': {"type": "LineString", "coordinates": [[1, 2], [2, 2]]}}})
|
self.assertEqual(update, {'$set': {'line': {"type": "LineString", "coordinates": [[1, 2], [2, 2]]}}})
|
||||||
|
|
||||||
def test_geojson_PolygonField(self):
|
def test_geojson_PolygonField(self):
|
||||||
class Location(Document):
|
class Location(Document):
|
||||||
poly = PolygonField()
|
poly = PolygonField()
|
||||||
|
|
||||||
update = transform.update(Location, set__poly=[[[40, 5], [40, 6], [41, 6], [40, 5]]])
|
update = transform.update(Location, set__poly=[[[40, 5], [40, 6], [41, 6], [40, 5]]])
|
||||||
self.assertEquals(update, {'$set': {'poly': {"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]}}})
|
self.assertEqual(update, {'$set': {'poly': {"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]}}})
|
||||||
|
|
||||||
update = transform.update(Location, set__poly={"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]})
|
update = transform.update(Location, set__poly={"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]})
|
||||||
self.assertEquals(update, {'$set': {'poly': {"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]}}})
|
self.assertEqual(update, {'$set': {'poly': {"type": "Polygon", "coordinates": [[[40, 5], [40, 6], [41, 6], [40, 5]]]}}})
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user