Exemplo n.º 1
0
    def test_remove_line(self):
      crontab = Crontab()
      linea = u'linea de prueba'
      not_erased_line = 'linea no borrada'

      crontab.add_line(linea)

      comando = ['sudo', 'grep', linea, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertEqual(0,subprocess.call(comando, stdout=fnull))

      crontab.add_line(not_erased_line)

      comando = ['sudo', 'grep', not_erased_line, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertEqual(0,subprocess.call(comando, stdout=fnull))

      crontab.remove_line(linea)

      comando = ['sudo', 'grep', linea, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertNotEqual(0,subprocess.call(comando, stdout=fnull))

      """
      Is verified that was not erased the line that has not to be deleted.
      """
      comando = ['sudo', 'grep', not_erased_line, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertEqual(0,subprocess.call(comando, stdout=fnull))

      crontab.remove_line(not_erased_line)
Exemplo n.º 2
0
    def test_remove_line(self):
        crontab = Crontab()
        linea = u'linea de prueba'
        not_erased_line = 'linea no borrada'

        crontab.add_line(linea)

        comando = ['sudo', 'grep', linea, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertEqual(0, subprocess.call(comando, stdout=fnull))

        crontab.add_line(not_erased_line)

        comando = ['sudo', 'grep', not_erased_line, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertEqual(0, subprocess.call(comando, stdout=fnull))

        crontab.remove_line(linea)

        comando = ['sudo', 'grep', linea, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertNotEqual(0, subprocess.call(comando, stdout=fnull))
        """
      Is verified that was not erased the line that has not to be deleted.
      """
        comando = ['sudo', 'grep', not_erased_line, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertEqual(0, subprocess.call(comando, stdout=fnull))

        crontab.remove_line(not_erased_line)
Exemplo n.º 3
0
    def test_add_line(self):
      crontab = Crontab()
      linea = u'linea de prueba'
      crontab.add_line(linea)
      comando = ['sudo', 'grep', linea, crontab.get_crontab()]
      with open(os.devnull,'w') as fnull:
        self.assertEqual(0,subprocess.call(comando, stdout=fnull))

      crontab.remove_line(linea)
Exemplo n.º 4
0
    def test_add_line(self):
        crontab = Crontab()
        linea = u'linea de prueba'
        crontab.add_line(linea)
        comando = ['sudo', 'grep', linea, crontab.get_crontab()]
        with open(os.devnull, 'w') as fnull:
            self.assertEqual(0, subprocess.call(comando, stdout=fnull))

        crontab.remove_line(linea)
Exemplo n.º 5
0
 def remove_domain_update_from_crontab(self, domain, user):
     line = '%s?host=%s&api_key=%s' % (self.__base_url_service, domain,
                                       self.__api_key)
     from iampacks.cross.crontab.models import Crontab
     crontab = Crontab(user=user)
     crontab.remove_line(line)
Exemplo n.º 6
0
 def remove_domain_update_from_crontab(self,domain,user):
   line = '%s?host=%s&api_key=%s'%(self.__base_url_service, domain,self.__api_key)
   from iampacks.cross.crontab.models import Crontab
   crontab = Crontab(user=user)
   crontab.remove_line(line)