Exemple #1
0
 def test_delete(self):
   """
   Test to delete workspace.
   """
   workspace = Workspace(self.WORKSPACE, 1)
   workspace.create()
   assert os.path.exists(self.WORKSPACE)
   workspace.delete()
   self.assertFalse(os.path.exists(self.WORKSPACE))
Exemple #2
0
 def test_create(self):
   """
   Test to delete workspace.
   """
   num = 10
   workspace = Workspace(self.WORKSPACE, num)
   workspace.create()
   for i in xrange(0, num):
     assert os.path.exists('%s/%d' % (self.WORKSPACE, i))
   workspace.delete()
   self.assertFalse(os.path.exists(self.WORKSPACE))
Exemple #3
0
    def setup_environment(self):
        """
    Create directories and database used for the scan.
    """
        # Reduce the numbers of servers and browsers if the max_scan value is small.
        if self.max_scan > 0:
            if self.max_scan < self.server_count:
                self.server_count = self.max_scan
            if self.max_scan < self.browser_count:
                self.browser_count = self.max_scan

        adscan.fs.makedirs(self.log_dir)

        self.workspace = Workspace(self.tmp_dir, self.browser_count)
        self.workspace.create()

        self.db_session = adscan.db.new_session(self.creative_db,
                                                [Creative, ScanLog])
Exemple #4
0
 def test_move_netlog(self):
   """
   Test to move network logs.
   """
   dest_dir = 'dest'
   num = 10
   workspace = Workspace(self.WORKSPACE, num)
   workspace.create()
   for i in xrange(0, num):
     dirname = '%s/%d' % (self.WORKSPACE, i)
     assert os.path.exists(dirname)
     for j in xrange(0, num):
       filename = '%s/%d_%d.json' % (dirname, i, j)
       open(filename, 'a').close()
       assert os.path.exists(filename)
   workspace.move_netlog(dest_dir)
   for i in xrange(0, num):
     for j in xrange(0, num):
       filename = '%s/%d_%d.json' % (dest_dir, i, j)
       assert os.path.exists(filename)
   workspace.delete()
   self.assertFalse(os.path.exists(self.WORKSPACE))