Beispiel #1
0
    def test_instantiate_empty_entrypoint(self):
        doc = OBInstance("CutSheet", self.taxonomy)

        # The newly initialized CutSheet should have a correct list of
        # allowable concepts as defined by the taxonomy for CutSheets.

        # TypeOfDevice is allowed in CutSheets:
        self.assertTrue(doc.is_concept_writable('solar:TypeOfDevice'))
        # AppraisalCounterparties is not allowed in CutSheets:
        self.assertFalse(
            doc.is_concept_writable('solar:AppraisalCounterparties'))

        # The newly initialized CutSheet should have a correct list of tables
        # and each table should have a correct list of axes, as defined by
        # the taxonomy for CutSheets:
        tables = doc.get_table_names()
        self._check_arrays_equivalent(
            tables,
            ["solar:InverterPowerLevelTable", "solar:CutSheetDetailsTable"])
        self._check_arrays_equivalent(
            doc.get_table("solar:InverterPowerLevelTable").get_axes(), [
                "solar:ProductIdentifierAxis",
                "solar:InverterPowerLevelPercentAxis"
            ])
        self._check_arrays_equivalent(
            doc.get_table("solar:CutSheetDetailsTable").get_axes(),
            ["solar:ProductIdentifierAxis", "solar:TestConditionAxis"])
Beispiel #2
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 = OBInstance("CutSheet", self.taxonomy)
        table = doc.get_table("solar:CutSheetDetailsTable")

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

        self.assertFalse(
            table.is_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.validate_context(concept, context)
Beispiel #3
0
    def test_hypercube_store_context(self):
        doc = OBInstance("CutSheet", self.taxonomy)
        table = doc.get_table("solar:InverterPowerLevelTable")

        c1 = table.store_context(
            Context(duration="forever",
                    entity="JUPITER",
                    ProductIdentifierAxis="ABCD",
                    InverterPowerLevelPercentAxis=
                    'solar:InverterPowerLevel50PercentMember'))
        self.assertEqual(c1.get_id(), "solar:InverterPowerLevelTable_0")
        c2 = table.store_context(
            Context(duration="forever",
                    entity="JUPITER",
                    ProductIdentifierAxis="ABCD",
                    InverterPowerLevelPercentAxis=
                    'solar:InverterPowerLevel50PercentMember'))  # Same
        self.assertIs(c1, c2)
        c3 = table.store_context(
            Context(duration="forever",
                    entity="JUPITER",
                    ProductIdentifierAxis="ABCD",
                    InverterPowerLevelPercentAxis=
                    'solar:InverterPowerLevel75PercentMember'))  # Different
        self.assertIsNot(c1, c3)
Beispiel #4
0
    def test_hypercube_can_identify_axis_domains(self):
        doc = OBInstance("CutSheet", self.taxonomy)
        table = doc.get_table("solar:CutSheetDetailsTable")

        domain = table.get_domain("solar:ProductIdentifierAxis")
        self.assertEqual(domain, "solar:ProductIdentifierDomain")

        domain = table.get_domain("solar:TestConditionAxis")
        self.assertEqual(domain, "solar:TestConditionDomain")