'Test document in list, dict, set.'

def test_document_hash(self):

    class User(Document, ):
        pass
    class BlogPost(Document, ):
        pass
    User.drop_collection()
    BlogPost.drop_collection()
    u1 = User.objects.create()
    u2 = User.objects.create()
    u3 = User.objects.create()
    u4 = User()
    b1 = BlogPost.objects.create()
    b2 = BlogPost.objects.create()
    all_user_list = list(User.objects.all())
    self.assertTrue((u1 in all_user_list))
    self.assertTrue((u2 in all_user_list))
    self.assertTrue((u3 in all_user_list))
    self.assertTrue((u4 not in all_user_list))
    self.assertTrue((b1 not in all_user_list))
    self.assertTrue((b2 not in all_user_list))
    all_user_dic = {}
    for u in User.objects.all():
        all_user_dic[u] = 'OK'
    self.assertEqual(all_user_dic.get(u1, False), 'OK')
    self.assertEqual(all_user_dic.get(u2, False), 'OK')
    self.assertEqual(all_user_dic.get(u3, False), 'OK')
    self.assertEqual(all_user_dic.get(u4, False), False)
    self.assertEqual(all_user_dic.get(b1, False), False)
    self.assertEqual(all_user_dic.get(b2, False), False)
    all_user_set = set(User.objects.all())
    self.assertTrue((u1 in all_user_set))
    self.assertTrue((u4 not in all_user_set))
    self.assertTrue((b1 not in all_user_list))
    self.assertTrue((b2 not in all_user_list))
    self.assertEqual(len(all_user_set), 3)
    all_user_set.add(u1)
    all_user_set.add(u2)
    all_user_set.add(u3)
    self.assertEqual(len(all_user_set), 3)
