def test_form_relate(self):
     form = RelatePopitInstanceWithWriteItInstance(data=self.data, writeitinstance=self.writeitinstance)
     form.is_valid()
     form.relate()
     records = WriteitInstancePopitInstanceRecord.objects.filter(writeitinstance=self.writeitinstance)
     self.assertEquals(records.count(), 1)
     self.assertTrue(self.writeitinstance.persons.all())
 def test_form_relate(self):
     form = RelatePopitInstanceWithWriteItInstance(data=self.data, writeitinstance=self.writeitinstance)
     form.is_valid()
     form.relate()
     records = WriteitInstancePopitInstanceRecord.objects.filter(writeitinstance=self.writeitinstance)
     self.assertEquals(records.count(), 1)
     self.assertTrue(self.writeitinstance.persons.all())
    def test_get_the_url(self):
        form = RelatePopitInstanceWithWriteItInstance(data=self.data, writeitinstance=self.writeitinstance)
        form.is_valid()
        form.relate()

        self.client.login(username="******", password="******")
        url = reverse('relate-writeit-popit', subdomain=self.writeitinstance.slug)
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        self.assertIn('relations', response.context)
        self.assertEquals(len(response.context['relations']), self.writeitinstance.writeitinstancepopitinstancerecord_set.count())
        self.assertTemplateUsed(response, 'nuntium/profiles/writeitinstance_and_popit_relations.html')
        self.assertEquals(response.context['relations'][0], self.writeitinstance.writeitinstancepopitinstancerecord_set.all()[0])
    def test_get_the_url(self):
        form = RelatePopitInstanceWithWriteItInstance(data=self.data, writeitinstance=self.writeitinstance)
        form.is_valid()
        form.relate()

        self.client.login(username="******", password="******")
        url = reverse('relate-writeit-popit', subdomain=self.writeitinstance.slug)
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        self.assertIn('relations', response.context)
        self.assertEquals(len(response.context['relations']), self.writeitinstance.writeitinstancepopitinstancerecord_set.count())
        self.assertTemplateUsed(response, 'nuntium/profiles/writeitinstance_and_popit_relations.html')
        self.assertEquals(response.context['relations'][0], self.writeitinstance.writeitinstancepopitinstancerecord_set.all()[0])