Beispiel #1
0
    def test_hypercube_rejects_out_of_domain_axis_values(self):
        # Try passing in something as a value for TestConditionAxis that is not
        # one of the enumerated Members; it should be rejected:

        doc = Entrypoint("CutSheet", self.taxonomy)
        table = doc.get_table("solar:CutSheetDetailsTable")

        self.assertTrue(
            table.axis_value_within_domain(
                "solar:TestConditionAxis",
                "solar:StandardTestConditionMember"))

        self.assertFalse(
            table.axis_value_within_domain(
                "solar:TestConditionAxis",
                "solar:InverterPowerLevel100PercentMember"))

        concept = 'solar:InverterOutputRatedPowerAC'
        context = Context(
            duration="forever",
            ProductIdentifierAxis="placeholder",
            InverterPowerLevelPercentAxis='solar:StandardTestConditionMember')
        # not a valid value for InverterPowerLevelPercentAxis
        with self.assertRaises(Exception):
            doc.sufficient_context(concept, context)
Beispiel #2
0
    def test_hypercube_rejects_context_with_unwanted_axes(self):
        # Test that giving a context an *extra* axis that is invalid for the table
        # causes it to be rejected as well.
        doc = Entrypoint("CutSheet", self.taxonomy)

        twoAxisContext = Context(
            ProductIdentifierAxis="placeholder",
            TestConditionAxis="solar:StandardTestConditionMember",
            instant=datetime.now())
        self.assertTrue(
            doc.sufficient_context("solar:DeviceCost", twoAxisContext))

        threeAxisContext = Context(
            ProductIdentifierAxis="placeholder",
            InverterPowerLevelPercentAxis=
            'solar:InverterPowerLevel50PercentMember',
            TestConditionAxis="solar:StandardTestConditionMember",
            instant=datetime.now())
        # InverterPowerLevelPercentAxis is a valid axis and this is a valid value for it,
        # but the table that holds DeviceCost doesn't want this axis:
        with self.assertRaises(Exception):
            doc.sufficient_context("solar:DeviceCost", threeAxisContext)
Beispiel #3
0
    def test_sufficient_context_instant_vs_duration(self):
        doc = Entrypoint("CutSheet", self.taxonomy)

        # in order to set a concept value, sufficient context must be
        # provided. what is sufficient context varies by concept.
        # in general the context must provide the correct time information
        # (either duration or instant)

        # We shouldn't even be able to instantiate a context with no time info:
        with self.assertRaises(Exception):
            noTimeContext = Context(
                ProductIdentifierAxis="placeholder",
                TestConditionAxis="solar:StandardTestConditionMember")

        # solar:DeviceCost has period_type instant
        # so it requires a context with an instant. A context without an instant
        # should be insufficient:
        instantContext = Context(
            ProductIdentifierAxis="placeholder",
            TestConditionAxis="solar:StandardTestConditionMember",
            instant=datetime.now())
        durationContext = Context(
            ProductIdentifierAxis="placeholder",
            TestConditionAxis="solar:StandardTestConditionMember",
            duration="forever")

        self.assertTrue(
            doc.sufficient_context("solar:DeviceCost", instantContext))
        # A context with a duration instead of an instant should also be
        # rejected:
        with self.assertRaises(Exception):
            doc.sufficient_context("solar:DeviceCost", durationContext)

        # solar:ModuleNameplateCapacity has period_type duration.
        # A context with an instant instead of a duration should also be
        # rejected:
        with self.assertRaises(Exception):
            doc.sufficient_context("solar:ModuleNameplateCapacity",
                                   instantContext)
        self.assertTrue(
            doc.sufficient_context("solar:ModuleNameplateCapacity",
                                   durationContext))
Beispiel #4
0
    def test_sufficient_context_axes(self):
        doc = Entrypoint("CutSheet", self.taxonomy)

        # The context must also provide all of the axes needed to place the
        # fact within the right table.

        # DeviceCost is on the CutSheetDetailsTable so it needs a value
        # for ProductIdentifierAxis and TestConditionAxis.
        with self.assertRaises(Exception):
            doc.sufficient_context("solar:DeviceCost", {})

        context = Context(
            instant=datetime.now(),
            ProductIdentifierAxis="placeholder",
            TestConditionAxis="solar:StandardTestConditionMember")
        self.assertTrue(doc.sufficient_context("solar:DeviceCost", context))

        badContext = Context(
            instant=datetime.now(),
            TestConditionAxis="solar:StandardTestConditionMember")
        with self.assertRaises(Exception):
            doc.sufficient_context("solar:DeviceCost", badContext)

        badContext = Context(instant=datetime.now(),
                             ProductIdentifierAxis="placeholder")
        with self.assertRaises(Exception):
            doc.sufficient_context("solar:DeviceCost", badContext)

        # How do we know what are valid values for ProductIdentifierAxis and
        # TestConditionAxis?  (I think they are meant to be UUIDs.)

        # Note: TestConditionAxis is part of the following relationships:
        # solar:TestConditionAxis -> dimension-domain -> solar:TestConditionDomain
        # solar:TestConditionAxis -> dimension-default -> solar:TestConditionDomain
        # i wonder what that "dimension-default" means

        #'solar:InverterOutputRatedPowerAC' is on the 'solar:InverterPowerLevelTable' which requires axes: [u'solar:ProductIdentifierAxis', u'solar:InverterPowerLevelPercentAxis']. it's a duration.
        concept = 'solar:InverterOutputRatedPowerAC'
        context = Context(duration="forever",
                          ProductIdentifierAxis="placeholder",
                          InverterPowerLevelPercentAxis=
                          'solar:InverterPowerLevel100PercentMember')

        self.assertTrue(doc.sufficient_context(concept, context))

        badContext = Context(instant=datetime.now(),
                             InverterPowerLevelPercentAxis=
                             'solar:InverterPowerLevel100PercentMember')
        with self.assertRaises(Exception):
            doc.sufficient_context(concept, badContext)

        badContext = Context(instant=datetime.now(),
                             ProductIdentifierAxis="placeholder")
        with self.assertRaises(Exception):
            doc.sufficient_context(concept, badContext)