Esempio n. 1
0
def test_survey_create_diff(job_template, survey_spec_factory):
    old = JobTemplate.objects.get(pk=job_template.pk)
    job_template.survey_spec = survey_spec_factory('foo')
    before, after = model_instance_diff(
        old, job_template, model_serializer_mapping())['survey_spec']
    assert before == '{}'
    assert json.loads(after) == survey_spec_factory('foo')
def test_modified_not_allowed_field(somecloud_type):
    """
    If this test fails, that means that read-only fields are showing
    up in the activity stream serialization of an instance.

    That _probably_ means that you just connected a new model to the
    activity_stream_registrar, but did not add its serializer to
    the model->serializer mapping.
    """
    from awx.main.registrar import activity_stream_registrar

    for Model in activity_stream_registrar.models:
        assert 'modified' not in get_allowed_fields(Model(), model_serializer_mapping()), Model
Esempio n. 3
0
def test_missing_related_on_delete(inventory_source):
    old_is = InventorySource.objects.get(name=inventory_source.name)
    inventory_source.inventory.delete()
    d = model_to_dict(old_is, serializer_mapping=model_serializer_mapping())
    assert d['inventory'] == '<missing inventory source>-{}'.format(
        old_is.inventory_id)