Beispiel #1
0
    def testCreateFinished(self, mock_time):  # pylint: disable=no-self-use
        """Test create finished job."""
        os.environ["REPO_OWNER"] = "fake_org"
        os.environ["REPO_NAME"] = "fake_name"
        os.environ["PULL_REFS"] = "master:abcd,72:efgh"
        mock_time.return_value = 1000
        workflow_phase = {"wfA": "Succeeded"}
        test_urls = {
            "wfA": "https://example.com",
        }
        expected = {
            "timestamp": 1000,
            "result": "FAILED",
            "metadata": {
                "repos": {
                    "fake_org/fake_name": "master:abcd,72:efgh"
                },
                "wfA-phase": "Succeeded",
                "wfA-ui": "https://example.com",
            },
        }

        actual = prow_artifacts.create_finished(False, workflow_phase,
                                                test_urls)
        os.environ.pop("PULL_REFS")
        self.assertEqual(expected, json.loads(actual))
Beispiel #2
0
    def testCreateFinished(self, mock_time):  # pylint: disable=no-self-use
        """Test create finished job."""
        mock_time.return_value = 1000

        expected = {
            "timestamp": 1000,
            "result": "FAILED",
            "metadata": {},
        }

        actual = prow_artifacts.create_finished(False)

        self.assertEquals(expected, json.loads(actual))
Beispiel #3
0
    def testCreateFinished(self, mock_time):  # pylint: disable=no-self-use
        """Test create finished job."""
        mock_time.return_value = 1000
        workflow_phase = {"wfA": "Succeeded"}
        test_urls = {
            "wfA": "https://example.com",
        }
        expected = {
            "timestamp": 1000,
            "result": "FAILED",
            "metadata": {
                "wfA-phase": "Succeeded",
                "wfA-ui": "https://example.com",
            },
        }

        actual = prow_artifacts.create_finished(False, workflow_phase,
                                                test_urls)

        self.assertEqual(expected, json.loads(actual))
Beispiel #4
0
def create_finished_file(bucket, success):
    """Create the started file in gcs for gubernator."""
    contents = prow_artifacts.create_finished(success)

    target = os.path.join(prow_artifacts.get_gcs_dir(bucket), "finished.json")
    upload_to_gcs(contents, target)