Ejemplo n.º 1
0
    def testInt(self):
        
        status = Status.get_status_holder("UnitTest")
        status.reset()
        self.assertNotEqual(status, None)

        i = status.create_status_element("TestInteger")
        self.assertEquals(i.get_name(), "TestInteger")

        x = status.get_status_element("TestInteger")
        self.assertEquals(x, i)

        # Test set and get values
        for j in range(0,10):
            i.set_value(j)
            self.assertEquals(i.get_value(), j)

        # Clean up
        status.remove_status_element(i)
        try:
            status.get_status_element("TestInteger")
            self.fail("Remove does not remove status element 'TestInteger'")
        except Status.NoSuchElementException, e:
            # Expected
            pass
Ejemplo n.º 2
0
    def testPolicy_PERIODIC(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()

        reporter = TestPeriodicStatusReporter("Periodic, 0.4sec", 0.4)
        status.add_reporter(reporter)
        i = status.create_status_element("TestInteger")

        for x in range(0, 5):
            i.set_value(x)
            self.assertEquals(reporter.last_value, None) # Not updated yet
            
        time.sleep(1)
        
        assert reporter.last_value == 4

        for x in range(5, 9):
            self.assertEquals(reporter.last_value, 4) # Not updated yet
            i.set_value(x)
        time.sleep(1)

        self.assertEquals(reporter.last_value, 8)

        # Clean up
        status.remove_status_element(i)

        reporter.stop()
Ejemplo n.º 3
0
    def testPolicy_PERIODIC(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()

        reporter = TestPeriodicStatusReporter("Periodic, 0.4sec", 0.4)
        status.add_reporter(reporter)
        i = status.create_status_element("TestInteger")

        for x in range(0, 5):
            i.set_value(x)
            self.assertEquals(reporter.last_value, None)  # Not updated yet

        time.sleep(1)

        assert reporter.last_value == 4

        for x in range(5, 9):
            self.assertEquals(reporter.last_value, 4)  # Not updated yet
            i.set_value(x)
        time.sleep(1)

        self.assertEquals(reporter.last_value, 8)

        # Clean up
        status.remove_status_element(i)

        reporter.stop()
Ejemplo n.º 4
0
    def testInt(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()
        self.assertNotEqual(status, None)

        i = status.create_status_element("TestInteger")
        self.assertEquals(i.get_name(), "TestInteger")

        x = status.get_status_element("TestInteger")
        self.assertEquals(x, i)

        # Test set and get values
        for j in range(0, 10):
            i.set_value(j)
            self.assertEquals(i.get_value(), j)

        # Clean up
        status.remove_status_element(i)
        try:
            status.get_status_element("TestInteger")
            self.fail("Remove does not remove status element 'TestInteger'")
        except Status.NoSuchElementException, e:
            # Expected
            pass
Ejemplo n.º 5
0
    def testBasic(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()
        
        self.assertNotEqual(status, None)

        self.assertEquals(status.get_name(), "UnitTest")
Ejemplo n.º 6
0
    def testBasic(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()

        self.assertNotEqual(status, None)

        self.assertEquals(status.get_name(), "UnitTest")
Ejemplo n.º 7
0
    def testInvalid(self):
        status = Status.get_status_holder("UnitTest")
        status.reset()

        try:
            i = status.create_status_element(None)
            self.fail("Does not throw exception with no name")
        except AssertionError, e:
            pass
Ejemplo n.º 8
0
    def testInvalid(self):
        status = Status.get_status_holder("UnitTest")
        status.reset()

        try:
            i = status.create_status_element(None)
            self.fail("Does not throw exception with no name")
        except AssertionError, e:
            pass
Ejemplo n.º 9
0
    def test_LLReporter_element(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()
        reporter = TestLivingLabPeriodicReporter("Living lab test reporter", 1.0)
        status.add_reporter(reporter)
        i = status.create_status_element("TestInteger")
        i.set_value(1233)
        
        reporter.wait_for_post(5.0)

        reporter.stop()
        time.sleep(1)
        
        self.assertEquals(len(reporter.get_errors()), 0)

        status.remove_status_element(i)
Ejemplo n.º 10
0
    def testPolicy_ON_CHANGE(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()
        reporter = TestOnChangeStatusReporter("On change")
        status.add_reporter(reporter)
        i = status.create_status_element("TestInteger")

        for x in range(0, 10):
            i.set_value(x)
            if x != reporter.value:
                self.fail("Callback does not work for ON_CHANGE policy")
            if reporter.name != "TestInteger":
                self.fail("On_Change callback get's the wrong parameter, got '%s', expected 'TestInteger'"%reporter.name)

        # Clean up
        status.remove_status_element(i)
Ejemplo n.º 11
0
    def test_LLReporter_element(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()
        reporter = TestLivingLabPeriodicReporter("Living lab test reporter",
                                                 1.0)
        status.add_reporter(reporter)
        i = status.create_status_element("TestInteger")
        i.set_value(1233)

        reporter.wait_for_post(5.0)

        reporter.stop()
        time.sleep(1)

        self.assertEquals(len(reporter.get_errors()), 0)

        status.remove_status_element(i)
Ejemplo n.º 12
0
    def test_LLReporter_event(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()
        reporter = TestLivingLabPeriodicReporter("Living lab test reporter", 1.0)
        status.add_reporter(reporter)
        event = status.create_event("SomeEvent")
        event.add_value("123")
        event.add_value("456")
        status.add_event(event)
        
        reporter.wait_for_post(5.0)

        reporter.stop()
        time.sleep(1)
        
        self.assertEquals(len(reporter.get_errors()), 0)

        status.remove_event(event)
Ejemplo n.º 13
0
    def testPolicy_ON_CHANGE(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()
        reporter = TestOnChangeStatusReporter("On change")
        status.add_reporter(reporter)
        i = status.create_status_element("TestInteger")

        for x in range(0, 10):
            i.set_value(x)
            if x != reporter.value:
                self.fail("Callback does not work for ON_CHANGE policy")
            if reporter.name != "TestInteger":
                self.fail(
                    "On_Change callback get's the wrong parameter, got '%s', expected 'TestInteger'"
                    % reporter.name)

        # Clean up
        status.remove_status_element(i)
Ejemplo n.º 14
0
    def test_LLReporter_event(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()
        reporter = TestLivingLabPeriodicReporter("Living lab test reporter",
                                                 1.0)
        status.add_reporter(reporter)
        event = status.create_event("SomeEvent")
        event.add_value("123")
        event.add_value("456")
        status.add_event(event)

        reporter.wait_for_post(5.0)

        reporter.stop()
        time.sleep(1)

        self.assertEquals(len(reporter.get_errors()), 0)

        status.remove_event(event)
Ejemplo n.º 15
0
        except AssertionError, e:
            pass

        try:
            status.get_status_element(None)
            self.fail("Invalid get_status_element does not throw exception")
        except AssertionError, e:
            pass

        try:
            status.remove_status_element(None)
            self.fail("Invalid remove_status_element does not throw exception")
        except AssertionError, e:
            pass

        elem = Status.StatusElement("name", "description")
        try:
            status.remove_status_element(elem)
            self.fail("Invalid remove_status_element does not throw exception")
        except Status.NoSuchElementException, e:
            pass

    def testPolicy_ON_CHANGE(self):

        status = Status.get_status_holder("UnitTest")
        status.reset()
        reporter = TestOnChangeStatusReporter("On change")
        status.add_reporter(reporter)
        i = status.create_status_element("TestInteger")

        for x in range(0, 10):