'Ensure that query slicing an embedded array works.'

def test_slicing_nested_fields(self):

    class EmbeddedNumber(EmbeddedDocument, ):
        n = ListField(IntField())
    class Numbers(Document, ):
        embedded = EmbeddedDocumentField(EmbeddedNumber)
    Numbers.drop_collection()
    numbers = Numbers()
    numbers.embedded = EmbeddedNumber(n=[0, 1, 2, 3, 4, 5, (-5), (-4), (-3), (-2), (-1)])
    numbers.save()
    numbers = Numbers.objects.fields(slice__embedded__n=3).get()
    self.assertEqual(numbers.embedded.n, [0, 1, 2])
    numbers = Numbers.objects.fields(slice__embedded__n=(-3)).get()
    self.assertEqual(numbers.embedded.n, [(-3), (-2), (-1)])
    numbers = Numbers.objects.fields(slice__embedded__n=[2, 3]).get()
    self.assertEqual(numbers.embedded.n, [2, 3, 4])
    numbers = Numbers.objects.fields(slice__embedded__n=[(-5), 4]).get()
    self.assertEqual(numbers.embedded.n, [(-5), (-4), (-3), (-2)])
    numbers = Numbers.objects.fields(slice__embedded__n=[(-5), 10]).get()
    self.assertEqual(numbers.embedded.n, [(-5), (-4), (-3), (-2), (-1)])
    numbers = Numbers.objects.fields(embedded__n={'$slice': [(-5), 10]}).get()
    self.assertEqual(numbers.embedded.n, [(-5), (-4), (-3), (-2), (-1)])
