Пример #1
0
    def test_provider_stop_failed(self):
        """Test that the checkin method raises an IutCheckinFailed exception.

        Approval criteria:
            - The checkin method shall fail with an IutCheckinFailed exception.

        Test steps::
            1. Initialize an external provider.
            2. Send a stop request that fails.
            3. Verify that the checkin method raises IutCheckinFailed exception.
        """
        etos = ETOS("testing_etos", "testing_etos", "testing_etos")
        etos.config.set("WAIT_FOR_IUT_TIMEOUT", 1)
        jsontas = JsonTas()
        jsontas.dataset.merge({
            "identity":
            PackageURL.from_string("pkg:testing/etos"),
            "artifact_id":
            "artifactid",
            "artifact_created":
            "artifactcreated",
            "artifact_published":
            "artifactpublished",
            "tercc":
            "tercc",
            "dataset": {},
            "context":
            "context",
        })
        iut = Iut(test_iut=1)

        with FakeServer("bad_request", {"error": "no"}) as server:
            ruleset = {
                "id": "test_provider_stop_failed",
                "stop": {
                    "host": server.host
                }
            }
            self.logger.info("STEP: Initialize an external provider.")
            provider = Provider(etos, jsontas, ruleset)
            self.logger.info("STEP: Send a stop request that fails.")
            with self.assertRaises(IutCheckinFailed):
                self.logger.info(
                    "STEP: Verify that the checkin method raises IutCheckinFailed exception."
                )
                provider.checkin(iut)
Пример #2
0
    def test_provider_stop(self):
        """Test that it is possible to checkin an external IUT provider.

        Approval criteria:
            - It shall be possible to send stop to an external IUT provider.

        Test steps::
            1. Initialize an external provider.
            2. Send a stop request for a single IUT.
            3. Verify that the stop endpoint is called.
        """
        etos = ETOS("testing_etos", "testing_etos", "testing_etos")
        etos.config.set("WAIT_FOR_IUT_TIMEOUT", 1)
        jsontas = JsonTas()
        jsontas.dataset.merge({
            "identity":
            PackageURL.from_string("pkg:testing/etos"),
            "artifact_id":
            "artifactid",
            "artifact_created":
            "artifactcreated",
            "artifact_published":
            "artifactpublished",
            "tercc":
            "tercc",
            "dataset": {},
            "context":
            "context",
        })
        iut = Iut(test_iut=1)

        with FakeServer("no_content", {}) as server:
            ruleset = {
                "id": "test_provider_stop",
                "stop": {
                    "host": server.host
                }
            }
            self.logger.info("STEP: Initialize an external provider.")
            provider = Provider(etos, jsontas, ruleset)
            self.logger.info("STEP: Send a stop request for a single IUT.")
            provider.checkin(iut)
            self.logger.info("STEP: Verify that the stop endpoint is called.")
            self.assertEqual(server.nbr_of_requests, 1)
            self.assertEqual(server.requests, [[iut.as_dict]])