

def test_reverse_manager(self):
    normal1 = Normal.objects.language('en').get(pk=self.normal_id[1])
    simplerel = SimpleRelated.objects.language('en').create(normal=normal1, translated_field='test1')
    with translation.override('en'):
        self.assertEqual(normal1.manysimplerel.count(), 0)
        normal1.manysimplerel.add(simplerel)
        self.assertEqual(normal1.manysimplerel.count(), 1)
        self.assertEqual(normal1.manysimplerel.language().get().translated_field, 'test1')
        normal1.manysimplerel.clear()
        self.assertEqual(normal1.manysimplerel.count(), 0)
        simplerel2 = normal1.manysimplerel.create(normal=normal1, translated_field='test2')
        self.assertEqual(normal1.manysimplerel.count(), 1)
        self.assertEqual(normal1.manysimplerel.language().get().translated_field, 'test2')
        normal1.manysimplerel.remove(simplerel2)
        self.assertEqual(normal1.manysimplerel.count(), 0)

dataset/ETHPy150Open KristianOellegaard/django-hvad/hvad/tests/related.py ManyToManyTest.test_reverse_manager/original