Exemplo n.º 1
0
def test_validate_task_schema_with_deep_key():
    context = MagicMock()
    context.task = {"scopes": ["one:scope"]}

    with tempfile.NamedTemporaryFile("w+") as f:
        json.dump(_TASK_SCHEMA, f)
        f.seek(0)

        context.config = {"first_layer": {"second_layer": f.name}}
        client.validate_task_schema(context, schema_key="first_layer.second_layer")
Exemplo n.º 2
0
def test_validate_task_schema(raises, task):
    context = MagicMock()
    context.task = task

    with tempfile.NamedTemporaryFile('w+') as f:
        json.dump(_TASK_SCHEMA, f)
        f.seek(0)

        context.config = {'schema_file': f.name}
        if raises:
            with pytest.raises(TaskVerificationError):
                client.validate_task_schema(context)
        else:
            client.validate_task_schema(context)
Exemplo n.º 3
0
def test_validate_task_schema_with_deep_key():
    context = MagicMock()
    context.task = {'scopes': ['one:scope']}

    with tempfile.NamedTemporaryFile('w+') as f:
        json.dump(_TASK_SCHEMA, f)
        f.seek(0)

        context.config = {
            'first_layer': {
                'second_layer': f.name,
            }
        }
        client.validate_task_schema(context, schema_key='first_layer.second_layer')
Exemplo n.º 4
0
def test_validate_task_schema(raises, task):
    context = MagicMock()
    context.task = task

    with tempfile.NamedTemporaryFile("w+") as f:
        json.dump(_TASK_SCHEMA, f)
        f.seek(0)

        context.config = {"schema_file": f.name}
        if raises:
            with pytest.raises(TaskVerificationError):
                client.validate_task_schema(context)
        else:
            client.validate_task_schema(context)
Exemplo n.º 5
0
def test_validate_task_schema_with_deep_key():
    context = MagicMock()
    context.task = {'scopes': ['one:scope']}

    with tempfile.NamedTemporaryFile('w+') as f:
        json.dump(_TASK_SCHEMA, f)
        f.seek(0)

        context.config = {
            'first_layer': {
                'second_layer': f.name,
            }
        }
        client.validate_task_schema(context,
                                    schema_key='first_layer.second_layer')
Exemplo n.º 6
0
def validate_task_schema(context):
    """Perform a schema validation check against taks definition"""
    action = get_task_action(context)
    schema_key = SCHEMA_MAP.get(action)
    client.validate_task_schema(context, schema_key=schema_key)
Exemplo n.º 7
0
def test_validate_task(context):
    context.task = TaskGenerator().generate_task('aurora')
    validate_task_schema(context)
Exemplo n.º 8
0
def test_validate_real_life_tasks(context, task):
    context.task = task
    validate_task_schema(context)
Exemplo n.º 9
0
def validate_task_schema(context):
    """Perform a schema validation check against taks definition"""
    action = get_task_action(context.task, context.config)
    schema_key = 'release_schema_file' if utils.is_release_action(action) else 'schema_file'
    client.validate_task_schema(context, schema_key=schema_key)
Exemplo n.º 10
0
 def test_validate_task(self):
     self.context.task = TaskGenerator().generate_json()
     validate_task_schema(self.context)
Exemplo n.º 11
0
def test_missing_mandatory_urls_are_reported(context, task_defn):
    context.task = task_defn
    del context.task["scopes"]

    with pytest.raises(ScriptWorkerTaskException):
        validate_task_schema(context)
Exemplo n.º 12
0
def test_tag_info_invalid(context, task_defn, tag_info):
    context.task = task_defn
    context.task['payload']['tag_info'] = tag_info
    with pytest.raises(ScriptWorkerTaskException):
        validate_task_schema(context)
Exemplo n.º 13
0
def test_missing_mandatory_urls_are_reported(context, task_defn):
    context.task = task_defn
    del(context.task['scopes'])

    with pytest.raises(ScriptWorkerTaskException):
        validate_task_schema(context)
Exemplo n.º 14
0
 def test_invalid_task(self, schema):
     with open(BASIC_TASK, "r") as fh:
         task = json.load(fh)
     with pytest.raises(ScriptWorkerTaskException):
         client.validate_task_schema({'foo': task}, schema)
Exemplo n.º 15
0
 def test_validate_task(self, schema):
     with open(BASIC_TASK, "r") as fh:
         task = json.load(fh)
     client.validate_task_schema(task, schema)
Exemplo n.º 16
0
    def test_validate_real_life_tasks(self):
        beta_task = {
            "provisionerId": "scriptworker-prov-v1",
            "workerType": "pushapk-v1",
            "schedulerId": "gecko-level-3",
            "taskGroupId": "dG0aircORb-VaKCK8X-grw",
            "dependencies": [
                "TjtRhOazQJ6_lNYYDMjAGA",
                "R-GBCWrDQiW7UP1nPALXMg",
                "TmzjU_G6ReepFBGOCATlpw"
            ],
            "requires": "all-completed",
            "routes": [
                        "tc-treeherder.v2.mozilla-beta.35a1b06fe7863e118ce831d9056ad20501eec606.0",
                        "tc-treeherder-stage.v2.mozilla-beta.35a1b06fe7863e118ce831d9056ad20501eec606.0"
            ],
            "priority": "normal",
            "retries": 5,
            "created": "2017-04-11T03:47:20.427Z",
            "deadline": "2017-04-16T03:47:20.427Z",
            "expires": "2018-04-11T03:47:20.427Z",
            "scopes": [
                        "project:releng:googleplay:beta"
            ],
            "payload": {
                "upstreamArtifacts": [{
                    "paths": [
                        "public/build/target.apk"
                    ],
                    "taskId": "TjtRhOazQJ6_lNYYDMjAGA",
                    "taskType": "signing"
                }, {
                    "paths": [
                        "public/build/target.apk"
                    ],
                    "taskId": "TmzjU_G6ReepFBGOCATlpw",
                    "taskType": "signing"
                }
                ],
                "google_play_track": "production",
                "commit": True
            },
            "metadata": {
                "owner": "[email protected]",
                "source": "https://hg.mozilla.org/releases/mozilla-beta/file/35a1b06fe7863e118ce831d9056ad20501eec606/taskcluster/ci/push-apk",
                "description": "Publishes APK onto Google Play Store \
        ([Treeherder push](https://treeherder.mozilla.org/#/jobs?repo=mozilla-beta&revision=35a1b06fe7863e118ce831d9056ad20501eec606))",
                "name": "push-apk/opt"
            },
            "tags": {
                "createdForUser": "******"
            },
            "extra": {
                "treeherderEnv": [
                    "production",
                    "staging"
                ],
                "treeherder": {
                    "jobKind": "other",
                    "groupSymbol": "pub",
                    "collection": {
                        "opt": True
                    },
                    "machine": {
                        "platform": "Android"
                    },
                    "groupName": "APK publishing",
                    "tier": 2,
                    "symbol": "gp"
                }
            }
        }

        self.context.task = beta_task
        validate_task_schema(self.context)
Exemplo n.º 17
0
def validate_task_schema(context):
    """Perform a schema validation check against taks definition"""
    schema_key = get_schema_key_by_action(context)
    client.validate_task_schema(context, schema_key=schema_key)
Exemplo n.º 18
0
def test_no_error_is_reported_when_no_missing_url(context, task_defn):
    context.task = task_defn
    validate_task_schema(context)
Exemplo n.º 19
0
def test_validate_task(context):
    context.task = TaskGenerator().generate_json()
    validate_task_schema(context)
Exemplo n.º 20
0
def test_no_error_is_reported_when_no_missing_url(context, task_defn):
    context.task = task_defn
    validate_task_schema(context)
Exemplo n.º 21
0
 def test_validate_task(self, schema):
     with open(BASIC_TASK, "r") as fh:
         task = json.load(fh)
     client.validate_task_schema(task, schema)
Exemplo n.º 22
0
def validate_task_schema(context):
    """Perform a schema validation check against taks definition"""
    action = get_task_action(context.task, context.config)
    schema_key = "schema_files.{}".format(action)
    client.validate_task_schema(context, schema_key=schema_key)
Exemplo n.º 23
0
 def test_invalid_task(self, schema):
     with open(BASIC_TASK, "r") as fh:
         task = json.load(fh)
     with pytest.raises(ScriptWorkerTaskException):
         client.validate_task_schema({'foo': task}, schema)