コード例 #1
0
def test_subclass_types(rando):
    assert set(UnifiedJobTemplate._submodels_with_roles()) == set([
        ContentType.objects.get_for_model(JobTemplate).id,
        ContentType.objects.get_for_model(Project).id,
        ContentType.objects.get_for_model(WorkflowJobTemplate).id,
        ContentType.objects.get_for_model(WorkflowApprovalTemplate).id
    ])
コード例 #2
0
def test_incorrectly_formatted_variables():
    bad_data = '{"bar":"foo'
    accepted, ignored, errors = UnifiedJobTemplate(
    ).accept_or_ignore_variables(bad_data)
    assert not accepted
    assert ignored == bad_data
    assert 'Cannot parse as JSON' in str(errors['extra_vars'][0])
コード例 #3
0
def test_organization_copy_to_jobs():
    '''
    All unified job types should infer their organization from their template organization
    '''
    for cls in UnifiedJobTemplate.__subclasses__():
        if cls is WorkflowApprovalTemplate:
            continue  # these do not track organization
        assert 'organization' in cls._get_unified_job_field_names(), cls
コード例 #4
0
def test_unified_template_field_consistency():
    """
    Example of what is being tested:
    The endpoints /projects/N/ and /projects/ should have the same fields as
    that same project when it is serialized by the unified job template serializer
    in /unified_job_templates/
    """
    for cls in UnifiedJobTemplate.__subclasses__():
        detail_serializer = getattr(serializers,
                                    '{}Serializer'.format(cls.__name__))
        unified_serializer = serializers.UnifiedJobTemplateSerializer(
        ).get_sub_serializer(cls())
        assert set(detail_serializer().fields.keys()) == set(
            unified_serializer().fields.keys())