

def test_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(simplerel.manynormals.count(), 0)
        simplerel.manynormals.add(normal1)
        self.assertEqual(simplerel.manynormals.count(), 1)
        self.assertEqual(simplerel.manynormals.language().get().shared_field, NORMAL[1].shared_field)
        simplerel.manynormals.clear()
        self.assertEqual(simplerel.manynormals.count(), 0)
        normal2 = simplerel.manynormals.create(shared_field='shared_test', translated_field='test2')
        self.assertEqual(simplerel.manynormals.count(), 1)
        self.assertEqual(simplerel.manynormals.language().get().shared_field, 'shared_test')
        simplerel.manynormals.remove(normal2)
        self.assertEqual(simplerel.manynormals.count(), 0)

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