Example #1
0
    def test_build_staging(self):
        if os.path.isdir(self.stage_dir):
            shutil.rmtree(self.stage_dir)
        b = DNSBuilder(STAGE_DIR=self.stage_dir, PROD_DIR=self.prod_dir,
                       LOCK_FILE=self.lock_file)
        b.build_staging()
        # Make sure it made the staging dir
        self.assertTrue(os.path.isdir(self.stage_dir))
        # Ensure if fails if the directory exists
        self.assertRaises(BuildError, b.build_staging)
        # There shouldn't be errors because force=True
        b.build_staging(force=True)

        self.assertTrue(os.path.isdir(self.stage_dir))
        b.clear_staging()
        self.assertFalse(os.path.isdir(self.stage_dir))
        self.assertRaises(BuildError, b.clear_staging)
        b.clear_staging(force=True)
        self.assertFalse(os.path.isdir(self.stage_dir))
Example #2
0
 def test_build_svn(self):
     print "This will take a while, be patient..."
     b = DNSBuilder(STAGE_DIR=self.stage_dir, PROD_DIR=self.prod_dir,
                    LOCK_FILE=self.lock_file, LOG_SYSLOG=False,
                    FIRST_RUN=True, PUSH_TO_PROD=True)
     b.build_dns()
     #self.svn_info()
     s = SOA.objects.all()
     if len(s) > 0:
         s[0].dirty = True
         s[0].save()
     b.build_dns()
     #self.svn_info()
     b.build_dns()
Example #3
0
    def test_lock_unlock(self):
        if os.path.exists(self.lock_file):
            os.remove(self.lock_file)
        b = DNSBuilder(STAGE_DIR=self.stage_dir, PROD_DIR=self.prod_dir,
                       LOCK_FILE=self.lock_file)
        self.assertFalse(os.path.exists(self.lock_file))
        b.lock()
        self.assertTrue(os.path.exists(self.lock_file))
        for i in xrange(10):
            b.unlock()
            b.lock()

        b.unlock()
        self.assertTrue(os.path.exists(self.lock_file))

        b.lock()
        self.assertTrue(os.path.exists(self.lock_file))

        b.unlock()
        self.assertTrue(os.path.exists(self.lock_file))