'Ensure that a query using find_one returns a valid result.'

def test_find_one(self):

    person1 = self.Person(name='User    A', age=20)
    person1.save()
    person2 = self.Person(name='User    B', age=30)
    person2.save()
    person = self.Person.objects.first()
    self.assertTrue(isinstance(person, self.Person))
    self.assertEqual(person.name, 'User    A')
    self.assertEqual(person.age, 20)
    person = self.Person.objects(age=30).first()
    self.assertEqual(person.name, 'User    B')
    person = self.Person.objects(age__lt=30).first()
    self.assertEqual(person.name, 'User    A')
    person = self.Person.objects[0]
    self.assertEqual(person.name, 'User    A')
    person = self.Person.objects[1]
    self.assertEqual(person.name, 'User    B')
    with self.assertRaises(IndexError):
        self.Person.objects[2]
    person = self.Person.objects.with_id(person1.id)
    self.assertEqual(person.name, 'User    A')
    with self.assertRaises(InvalidQueryError):
        self.Person.objects(name='User    A').with_id(person1.id)
