def test_can_add_political_office(self, logging_mock):
        data = {'name': 'Deputado Federal'}
        political_office = PoliticalOffice.add_political_office(self.db, data)

        expect(political_office.name).to_equal('Deputado Federal')
        expect(logging_mock.mock_calls).to_include(
            call.debug('Added political office: "%s"', 'Deputado Federal')
        )
Esempio n. 2
0
    def post(self):
        post_data = loads(self.request.body)

        name = post_data.get('name')

        if not name:
            self.set_status(400, 'Invalid Political Office')
            return

        data = {'name': name}

        political_office = PoliticalOffice.add_political_office(self.db, data)
        self.write_json(political_office.to_dict())