def test_mailbox_create(self): """ test creating a mailbox """ try: slug = self.TEST_MAILBOX_SLUG + '_test_mailbox_create' mb_url = self.url_for('mailbox_rest', mailbox_slug=slug) assert get_mailbox(self.config, slug) is None c = self.get_test_app() self.login_as_admin(c) c.head(mb_url, status=404) c.put(mb_url, '{}', content_type="application/json", status=201) c.head(mb_url, status=200) mb = get_mailbox(self.config, slug) assert mb is not None assert is_mailbox(mb) finally: dbname = get_database_name(self.config, slug) couchdb = get_couchdb_server(self.config) if dbname in couchdb: del couchdb[dbname]
def create_test_mailbox(self, slug=None): if slug is None: slug = self.TEST_MAILBOX_SLUG c = self.get_test_app() self.login_as_admin(c) mb_url = self.url_for('mailbox_rest', mailbox_slug=slug) response = c.head(mb_url, status='*') if response.status_int != 404: response = c.delete(mb_url, status=200) c.put(mb_url, '{}', content_type="application/json", status=201) self.logout(c) return get_mailbox(self.config, slug)