def test_cpi_clears_communities(self): alice = self.make_participant('alice') alice.insert_into_communities(True, 'test', 'test') bob = self.make_participant('bob') bob.insert_into_communities(True, 'test', 'test') assert Community.from_slug('test').nmembers == 2 # sanity check with self.db.get_cursor() as cursor: alice.clear_personal_information(cursor) assert Community.from_slug('test').nmembers == 1
def test_joining_and_leaving_community(self): self.make_participant("alice", claimed_time='now') response = self.client.GET('/for/communities.json', auth_as='alice') assert len(json.loads(response.body)['communities']) == 0 response = self.client.POST('/for/communities.json', { 'name': 'Test', 'is_member': 'true' }, auth_as='alice') communities = json.loads(response.body)['communities'] assert len(communities) == 1 assert communities[0]['name'] == 'Test' assert communities[0]['nmembers'] == 1 response = self.client.POST('/for/communities.json', { 'name': 'Test', 'is_member': 'false' }, auth_as='alice') response = self.client.GET('/for/communities.json', auth_as='alice') assert len(json.loads(response.body)['communities']) == 0 # Check that the empty community was deleted community = Community.from_slug('test') assert not community
def test_joining_and_leaving_community(self): self.make_participant("alice", claimed_time='now') response = self.client.GET('/for/communities.json', auth_as='alice') assert len(json.loads(response.body)['communities']) == 0 response = self.client.POST( '/for/communities.json' , {'name': 'Test', 'is_member': 'true'} , auth_as='alice' ) communities = json.loads(response.body)['communities'] assert len(communities) == 1 assert communities[0]['name'] == 'Test' assert communities[0]['nmembers'] == 1 response = self.client.POST( '/for/communities.json' , {'name': 'Test', 'is_member': 'false'} , auth_as='alice' ) response = self.client.GET('/for/communities.json', auth_as='alice') assert len(json.loads(response.body)['communities']) == 0 # Check that the empty community was deleted community = Community.from_slug('test') assert not community