예제 #1
0
    def testWildcardAccept(self):
        # Accept everything
        config = ConstraintsConfig({})
        constraints = Constraints(config, universe=self.universe)

        self.assertTrue(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))

        # Accept everything
        constraints = Constraints(None, universe=self.universe)

        self.assertTrue(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))

        # Accept everything explicitly
        config = ConstraintsConfig({"accept": ["all"]})
        constraints = Constraints(config, universe=self.universe)

        self.assertTrue(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))

        # Accept all instrument A but reject everything else
        config = ConstraintsConfig({"accept": [{"instrument<A>": ["all"]}]})
        constraints = Constraints(config, universe=self.universe)

        self.assertTrue(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))
        self.assertFalse(constraints.isAcceptable(self.pviB))
예제 #2
0
    def testAcceptReject(self):
        # Reject everything except calexp
        config = ConstraintsConfig({"accept": ["calexp"], "reject": ["all"]})
        constraints = Constraints(config, universe=self.universe)

        self.assertTrue(constraints.isAcceptable(self.calexpA))
        self.assertFalse(constraints.isAcceptable(self.pviA))

        # Accept everything except calexp
        config = ConstraintsConfig({"reject": ["calexp"], "accept": ["all"]})
        constraints = Constraints(config, universe=self.universe)

        self.assertFalse(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))

        # Reject pvi but explicitly accept pvi for instrument A
        # Reject all instrument A but accept everything else
        # The reject here is superfluous
        config = ConstraintsConfig({"accept": [{"instrument<A>": ["pvi"]}], "reject": ["pvi"]})
        constraints = Constraints(config, universe=self.universe)

        self.assertFalse(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))
        self.assertFalse(constraints.isAcceptable(self.pviB))

        # Accept everything except pvi from other than instrument A
        config = ConstraintsConfig({"accept": ["all", {"instrument<A>": ["pvi"]}], "reject": ["pvi"]})
        constraints = Constraints(config, universe=self.universe)

        self.assertTrue(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))
        self.assertFalse(constraints.isAcceptable(self.pviB))
예제 #3
0
    def testSimpleAccept(self):
        config = ConstraintsConfig({"accept": ["calexp", "ExposureF"]})
        constraints = Constraints(config, universe=self.universe)

        self.assertTrue(constraints.isAcceptable(self.calexpA))
        self.assertFalse(constraints.isAcceptable(self.pviA))

        # Dimension accept
        config = ConstraintsConfig(
            {"accept": ["visit+physical_filter+instrument", "ExposureF"]})
        constraints = Constraints(config, universe=self.universe)

        self.assertTrue(constraints.isAcceptable(self.calexpA))
        self.assertFalse(constraints.isAcceptable(self.pviA))

        config = ConstraintsConfig(
            {"accept": ["visit+detector+instrument", "ExposureF"]})
        constraints = Constraints(config, universe=self.universe)

        self.assertFalse(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))
        self.assertTrue(constraints.isAcceptable(self.pviA))

        # Only accept instrument A pvi
        config = ConstraintsConfig({"accept": [{"instrument<A>": ["pvi"]}]})
        constraints = Constraints(config, universe=self.universe)

        self.assertFalse(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))
        self.assertFalse(constraints.isAcceptable(self.pviB))

        # Accept PVI for instrument B but not instrument A
        config = ConstraintsConfig(
            {"accept": ["calexp", {
                "instrument<B>": ["pvi"]
            }]})
        constraints = Constraints(config, universe=self.universe)

        self.assertTrue(constraints.isAcceptable(self.calexpA))
        self.assertFalse(constraints.isAcceptable(self.pviA))
        self.assertTrue(constraints.isAcceptable(self.pviB))
예제 #4
0
 def testEdgeCases(self):
     # Accept everything and reject everything
     config = ConstraintsConfig({"accept": ["all"], "reject": ["all"]})
     with self.assertRaises(ValidationError):
         Constraints(config, universe=self.universe)
예제 #5
0
    def testSimpleReject(self):
        config = ConstraintsConfig({"reject": ["calexp", "ExposureF"]})
        constraints = Constraints(config, universe=self.universe)

        self.assertFalse(constraints.isAcceptable(self.calexpA))
        self.assertTrue(constraints.isAcceptable(self.pviA))