def test_add_members_to_an_association(self):
     association = factories.AssociationFactory(administrator=self.user)
     self.assertEqual(len(association.members.all()), 0)
     new_user = factories.UserFactory(username='******')
     response = self.client.post('/api/associations/%s/members/%s/' %
                                 (association.id, new_user.id))
     self.assertEqual(201, response.status_code)
     association_updated = Association.objects.get(id=association.id)
     self.assertEqual(len(association_updated.members.all()), 1)
Exemple #2
0
 def setUp(self):
     self.address = factories.AddressFactory()
     self.address2 = factories.AddressFactory.create(title='Maison')
     self.user = factories.UserFactory.create(
         address=[self.address, self.address2])
     self.user2 = factories.UserFactory.create(
         address=[self.address, self.address2])
     self.association = factories.AssociationFactory(
         name="Association de jdupont", administrator=self.user)
     self.client.login(username=self.user.username, password="******")
 def test_association_to_json_method(self):
     user = factories.UserFactory()
     self.client.login(username=user.username, password="******")
     association = factories.AssociationFactory(name="toto")
     expected_association = {
         'id': association.id,
         'name': association.name,
         'address': association.address,
         'phone': association.phone,
         'url_site': association.url_site,
         'email': association.email,
         'administrator': association.administrator.serialize()
     }
     self.assertDictEqual(association.serialize(), expected_association)
    def test_create_bid_with_association(self):
        association = factories.AssociationFactory(name="Bid with association")
        bid = factories.BidFactory(association=association)

        self.assertEquals(association.name, bid.association.name)
 def test_create_association(self):
     association = factories.AssociationFactory(name="Association Lambda")
     self.assertEquals("Association Lambda", association.name)
 def test_get_association_with_user_is_staff(self):
     association = factories.AssociationFactory(administrator=self.user)
     response = self.client.get('/api/associations/%s/' % association.id)
     self.assertEquals(200, response.status_code)
     self.assertDictEqual({'association': association.serialize(True)},
                          json.loads(response.content.decode('utf-8')))
 def test_delete_association(self):
     association = factories.AssociationFactory(administrator=self.user)
     response = self.client.delete('/api/associations/%s/' % association.id)
     self.assertEqual(204, response.status_code)
     self.assertEqual(len(Association.objects.all()), 0)
 def test_get_all_associations(self):
     association = factories.AssociationFactory(administrator=self.user)
     response = self.client.get('/api/associations/')
     self.assertEquals(200, response.status_code)
     self.assertEquals({'associations': [association.serialize()]},
                       json.loads(response.content.decode('utf-8')))