

def test_many_to_many(self):
    p1 = models.Publication(id=None, title='The Python Journal')
    p1.save()
    p2 = models.Publication(id=None, title='Science News')
    p2.save()
    p3 = models.Publication(id=None, title='Science Weekly')
    p3.save()
    self.addCleanup(p1.delete)
    self.addCleanup(p2.delete)
    self.addCleanup(p3.delete)
    a1 = models.Article(id=None, headline='Django lets you build Web apps easily')
    a1.save()
    self.addCleanup(a1.delete)
    self.assertEqual(a1.id, 1)
    a1.publications.add(p1)
    pub_alias = adapter.DjangoClassAlias(models.Publication, None)
    art_alias = adapter.DjangoClassAlias(models.Article, None)
    test_publication = models.Publication.objects.filter(pk=1)[0]
    test_article = models.Article.objects.filter(pk=1)[0]
    attrs = pub_alias.getEncodableAttributes(test_publication)
    self.assertEqual(attrs, {
        'id': 1,
        'title': 'The Python Journal',
    })
    attrs = art_alias.getEncodableAttributes(test_article)
    self.assertEqual(attrs, {
        'headline': 'Django lets you build Web apps easily',
        'id': 1,
        'publications': [p1],
    })
    x = models.Article()
    art_alias.applyAttributes(x, {
        'headline': 'Test',
        'id': 1,
        'publications': [p1],
    })
    self.assertEqual(p3.headline, 'Test')
    self.assertEqual(x.id, 1)
    self.assertEqual(list(x.publications.all()), [p1])
    y = models.Article()
    attrs = art_alias.getDecodableAttributes(y, {
        'headline': 'Django lets you build Web apps easily',
        'id': 0,
        'publications': [],
    })
    self.assertEqual(attrs, {
        'headline': 'Django lets you build Web apps easily',
    })

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/PyAMF-0.6.1/pyamf/tests/adapters/test_django.py ForeignKeyTestCase.test_many_to_many/VarMisuse@319/438 `x`->`p3`