Exemple #1
0
    def test_query(self):
        """Test that the translation for the Query class works."""
        attribute_foo = Attribute("foo", int, True, "a foo attribute.")
        attribute_bar = Attribute("bar", str, True, "a bar attribute.")
        data_model_foobar = DataModel(
            "foobar", [attribute_foo, attribute_bar], "A foobar data model."
        )

        query = Query(
            [
                And(
                    [
                        Or(
                            [
                                Not(Constraint("foo", ConstraintType("==", 1))),
                                Not(Constraint("bar", ConstraintType("==", "baz"))),
                            ]
                        ),
                        Constraint("foo", ConstraintType("<", 2)),
                    ]
                )
            ],
            data_model_foobar,
        )

        oef_query = OEFObjectTranslator.to_oef_query(query)
        expected_query = OEFObjectTranslator.from_oef_query(oef_query)
        actual_query = query
        assert expected_query == actual_query
Exemple #2
0
 def test_attribute(self):
     """Test that the translation for the Attribute class works."""
     attribute = Attribute("foo", int, True, "a foo attribute.")
     oef_attribute = OEFObjectTranslator.to_oef_attribute(attribute)
     expected_attribute = OEFObjectTranslator.from_oef_attribute(oef_attribute)
     actual_attribute = attribute
     assert expected_attribute == actual_attribute
Exemple #3
0
 def test_data_model(self):
     """Test that the translation for the DataModel class works."""
     attribute_foo = Attribute("foo", int, True, "a foo attribute.")
     attribute_bar = Attribute("bar", str, True, "a bar attribute.")
     data_model_foobar = DataModel(
         "foobar", [attribute_foo, attribute_bar], "A foobar data model."
     )
     oef_data_model = OEFObjectTranslator.to_oef_data_model(data_model_foobar)
     expected_data_model = OEFObjectTranslator.from_oef_data_model(oef_data_model)
     actual_data_model = data_model_foobar
     assert expected_data_model == actual_data_model
Exemple #4
0
 def test_description(self):
     """Test that the translation for the Description class works."""
     attribute_foo = Attribute("foo", int, True, "a foo attribute.")
     attribute_bar = Attribute("bar", str, True, "a bar attribute.")
     data_model_foobar = DataModel(
         "foobar", [attribute_foo, attribute_bar], "A foobar data model."
     )
     description_foobar = Description(
         {"foo": 1, "bar": "baz"}, data_model=data_model_foobar
     )
     oef_description = OEFObjectTranslator.to_oef_description(description_foobar)
     expected_description = OEFObjectTranslator.from_oef_description(oef_description)
     actual_description = description_foobar
     assert expected_description == actual_description
     m_desc = iter(description_foobar.values)
     assert next(m_desc) == "foo"
     assert {"foo", "bar"} == set(iter(description_foobar))
Exemple #5
0
    def setup_class(cls):
        """
        Set the test up.

        Steps:
        - Register a service
        - Check that the registration worked.
        """
        cls.obj_transaltor = OEFObjectTranslator()