コード例 #1
0
    def handle(self, *args, **options):
        if len(args) != 2:
            raise CommandError("must provide a config.xml and jobtype")
        jobtype, filename = args

        with codecs.open(filename) as f:
            import_jobtype(
                f, jobtype, update=options["update"], stdout=self.stdout)

        transaction.commit_unless_managed()
コード例 #2
0
    def handle(self, *args, **options):
        if len(args) != 2:
            raise CommandError("must provide a config.xml and jobtype")
        jobtype, filename = args

        with codecs.open(filename) as f:
            import_jobtype(
                jobtype, f, update=options["update"], stdout=self.stdout)

        transaction.commit_unless_managed()
コード例 #3
0
    def test_import_job_creates_a_jobtype(self):
        """
        import_jobtype should create a jobtype with the correct name and
        content.
        """
        stdout = StringIO()
        import_jobtype("my test", StringIO("my test"), stdout=stdout)

        job = JobType.objects.get(name="my test")
        self.assertEqual("my test", job.config_xml)
        self.assertEqual("Jobtype created\n", stdout.getvalue())
コード例 #4
0
ファイル: test_jobs.py プロジェクト: bigkevmcd/capomastro
    def test_import_job_creates_a_jobtype(self):
        """
        import_jobtype should create a jobtype with the correct name and
        content.
        """
        stdout = StringIO()
        import_jobtype("my test", StringIO("my test"), stdout=stdout)

        job = JobType.objects.get(name="my test")
        self.assertEqual("my test", job.config_xml)
        self.assertEqual("Jobtype created\n", stdout.getvalue())
コード例 #5
0
    def test_import_job_fails_with_preexisting_jobtype(self):
        """
        import_jobtype should error if we already have a jobtype with the
        supplied name.
        """
        JobType.objects.create(name="my test", config_xml="testing")
        with self.assertRaises(CommandError) as cm:
            import_jobtype("my test", StringIO("new content"))

        self.assertEqual("Jobtype already exists", str(cm.exception))
        job = JobType.objects.get(name="my test")
        self.assertEqual("testing", job.config_xml)
コード例 #6
0
ファイル: test_jobs.py プロジェクト: bigkevmcd/capomastro
    def test_import_job_fails_with_preexisting_jobtype(self):
        """
        import_jobtype should error if we already have a jobtype with the
        supplied name.
        """
        JobType.objects.create(name="my test", config_xml="testing")
        with self.assertRaises(CommandError) as cm:
            import_jobtype("my test", StringIO("new content"))

        self.assertEqual("Jobtype already exists", str(cm.exception))
        job = JobType.objects.get(name="my test")
        self.assertEqual("testing", job.config_xml)
コード例 #7
0
ファイル: test_jobs.py プロジェクト: bigkevmcd/capomastro
    def test_import_job_updates_a_jobtype(self):
        """
        import_jobtype should update the content if we provide a true value for
        the update parameter.
        """
        stdout = StringIO()
        JobType.objects.create(name="my test", config_xml="testing")
        import_jobtype(
            "my test", StringIO("new content"), update=True, stdout=stdout)

        job = JobType.objects.get(name="my test")
        self.assertEqual("new content", job.config_xml)
        self.assertEqual("Jobtype updated\n", stdout.getvalue())
コード例 #8
0
    def test_import_job_updates_a_jobtype(self):
        """
        import_jobtype should update the content if we provide a true value for
        the update parameter.
        """
        stdout = StringIO()
        JobType.objects.create(name="my test", config_xml="testing")
        import_jobtype("my test",
                       StringIO("new content"),
                       update=True,
                       stdout=stdout)

        job = JobType.objects.get(name="my test")
        self.assertEqual("new content", job.config_xml)
        self.assertEqual("Jobtype updated\n", stdout.getvalue())