Exemplo n.º 1
0
    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]
Exemplo n.º 2
0
    def setUp(self):
        # XXX load it!
        self.config = {'web.apps': ['radarpost.web.api'], 
                       'web.debug': True,
                       'web.static_files_url': '/static',
                       'beaker.session.type': 'memory', 
                       'couchdb.users_database': self.TEST_USERS_DB,
                       'couchdb.address': 'http://localhost:5984',
                       'couchdb.prefix': 'radar/'
                       }

        self.url_gen = URLGenerator(build_routes(self.config), {})

        # set-up users database
        couchdb = get_couchdb_server(self.config)
        dbname = self.config['couchdb.users_database']
        if dbname in couchdb: 
            del couchdb[dbname]
        self._users_db = couchdb.create(dbname)
        
        # create an admin
        admin = User(username=self.TEST_ADMIN_USER,
                     password=self.TEST_ADMIN_PASSWORD)
        admin.roles = [ROLE_ADMIN]
        admin.store(self._users_db)
Exemplo n.º 3
0
    def setUp(self):
        self.config = load_test_config()
        self.url_gen = URLGenerator(build_routes(self.config), {})

        # set-up users database
        couchdb = get_couchdb_server(self.config)
        dbname = self.config['couchdb.users_database']
        if dbname in couchdb: 
            del couchdb[dbname]
        self._users_db = couchdb.create(dbname)
        
        # create an admin
        admin = User(username=self.config['test.admin_user'],
                     password=self.config['test.admin_password'])
        admin.roles = [ROLE_ADMIN]
        admin.store(self._users_db)
Exemplo n.º 4
0
 def tearDown(self):
     couchdb = get_couchdb_server(self.config)
     dbname = get_database_name(self.config, self.TEST_MAILBOX_SLUG)
     if dbname in couchdb:
         del couchdb[dbname]