예제 #1
0
    def test_update_status(self, mock_get_cosmos_client):
        dsh = DataSetHelper()

        latest_dataset_doc = {}
        latest_dataset_doc["version"] = 3
        latest_dataset_doc["builds"] = {"courses": {"status": "pending"}}
        latest_dataset_doc["updated_at"] = "dave"
        dsh.get_latest_doc = mock.MagicMock(return_value=latest_dataset_doc)

        dsh.cosmos_client.UpsertItem = mock.MagicMock()

        dsh.update_status("courses", "in progress", "dave")

        expected_connection_link = (
            "dbs/test-db-id/colls/test-dataset-collection-id")
        expected_dataset_doc = {}
        expected_dataset_doc["version"] = 3
        expected_dataset_doc["builds"] = {"courses": {"status": "in progress"}}
        expected_dataset_doc["updated_at"] = "dave"
        dsh.cosmos_client.UpsertItem.assert_called_once_with(
            expected_connection_link, expected_dataset_doc)
예제 #2
0
    def test_have_all_builds_succeeded_with_one_pending(
            self, mock_get_cosmos_client):
        dsh = DataSetHelper()

        latest_dataset_doc = {}
        latest_dataset_doc["version"] = 3
        latest_dataset_doc["builds"] = {
            "courses": {
                "status": "pending"
            },
            "institutions": {
                "status": "succeeded"
            },
            "search": {
                "status": "succeeded"
            },
            "subjects": {
                "status": "succeeded"
            },
        }
        dsh.get_latest_doc = mock.MagicMock(return_value=latest_dataset_doc)
        self.assertFalse(dsh.have_all_builds_succeeded())