示例#1
0
    def test_task_are_in_task_to_json(self, mock_conn):
        task = Task(mock_conn, "task-name")
        task.completion_ttl = "4.11:08:06"
        task.auto_delete = True
        json_task = task._to_json()  # pylint: disable=protected-access

        assert json_task['completionTimeToLive'] == '4.11:08:06'
        assert json_task['autoDeleteOnCompletion'] is True
    def test_task_are_in_task_to_json(self):
        task = Task(self.conn, "task-name")
        task.completion_ttl = "4.11:08:06"
        task.auto_delete = True
        json_task = task._to_json()

        assert json_task['completionTimeToLive'] == '4.11:08:06'
        assert json_task['autoDeleteOnCompletion'] == True
示例#3
0
    def test_advance_bucket_in_task_to_json(self, mock_conn):
        task = Task(mock_conn, "task-name", "profile")
        bucket = Bucket(mock_conn, "name", False)
        bucket2 = bucket.with_filtering(BucketPrefixFiltering(
            "prefix1")).with_resource_transformation(PrefixResourcesTransformation("prefix2"))

        task.resources.append(bucket2)
        json_task = task._to_json()
        json_bucket = json_task["advancedResourceBuckets"][0]
        assert "name" == json_bucket["bucketName"]
        assert "prefix1" == json_bucket["filtering"]["prefixFiltering"]["prefix"]
        assert "prefix2" == json_bucket["resourcesTransformation"]["stripPrefix"]["prefix"]
示例#4
0
    def test_task_privileges(self, mock_conn):
        task = Task(mock_conn, "task-name")
        task.allow_credentials_to_be_exported_to_task_environment()
        assert task.privileges is not None
        assert task.privileges._exportApiAndStorageCredentialsInEnvironment == True

        json_task = task._to_json()
        assert json_task['privileges'] is not None
        assert json_task['privileges']['exportApiAndStorageCredentialsInEnvironment'] is True

        # fields that need to be non null for the deserialization to not fail
        json_task['creationDate'] = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
        json_task['uuid'] = str(uuid.uuid4())
        json_task['state'] = 'Submitted'
        json_task['runningCoreCount'] = 0
        json_task['runningInstanceCount'] = 0

        pool_from_json = Task(mock_conn, "task-name")
        pool_from_json._update(json_task)
        assert pool_from_json.privileges is not None
        assert pool_from_json.privileges._exportApiAndStorageCredentialsInEnvironment is True
示例#5
0
 def test_task_property_send_to_json_representation(self, mock_conn, property_name, expected_value):
     task = Task(mock_conn, "task-name")
     task._update(default_json_task)
     task_json = task._to_json()
     assert task_json[property_name] == expected_value