def setup(self): self.conn_string = ( 'driver={0};server={1};port={2};uid={3};pwd={4}'.format( self.conf.driver, self.conf.db_ip, self.conf.db_port, self.conf.db_username, self.conf.db_password)) nsodbc = nsodbc_factory() self.conn = nsodbc.connect(self.conn_string) self.switch_database, exists = self.conn.create(self.conf.switches_doc) if not exists: init_switch_db(self.switch_database) self.flow_database, exists = self.conn.create(self.conf.flows_doc) if not exists: init_flow_db(self.flow_database) self.db_update_counter = int(self.conf.db_update_counter)
def test_refresh_flow(self): """ Check that it refreshes the data related to the flows by deleting the existing flow database, and replacing it with a new one. """ g_db = nsodbc.nsodbc_factory() self.couch.conn = g_db.connect(**self.credentials) self.server.db.add(self.conf.flows_doc) test_file = self.conf.flows_doc + '/test_file' self.server.docs[test_file] = {'key1': 'val1'} self.couch.refresh_flowdb() flow_doc = self.get_doc_name(self.conf.flows_doc, 'match_view') self.assertTrue(flow_doc in self.server.docs) self.assertFalse(test_file in self.server.docs) self.assertTrue(self.conf.flows_doc in self.server.db)