Skip to content

conftest

hub_and_project(mockgun_project)

Fixture that sets up the AyonShotgridHub and related mock entities.

Source code in services/tests/conftest.py
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
@pytest.fixture
def hub_and_project(mockgun_project):
    """Fixture that sets up the AyonShotgridHub and related mock entities."""
    mg, project = mockgun_project

    hub = AyonShotgridHub(
        mg,
        "test_project",
        "test",
        sg_project_code_field="code",
        sg_enabled_entities=(
            "Episode",
            "Sequence",
            "Shot",
            "Asset",
        ),
    )

    entity_hub = MockEntityHub("test_project")

    project_entity = MockFolderEntity(
        "test_project",
        "Project",
        parent_id=None,
        entity_hub=entity_hub,
        attribs={
            constants.SHOTGRID_ID_ATTRIB: str(project["id"]),
            constants.SHOTGRID_TYPE_ATTRIB: "Project",
        }
    )

    # Inject mock entity hub into the hub
    hub._ay_project = entity_hub

    return {
        "hub": hub,
        "entity_hub": entity_hub,
        "project_entity": project_entity,
        "mg": mg,
        "project": project,
    }

mockgun_project()

Fixture that returns a mockgun instance and a created project.

Source code in services/tests/conftest.py
45
46
47
48
49
50
51
52
53
54
55
56
57
@pytest.fixture
def mockgun_project():
    """Fixture that returns a mockgun instance and a created project."""
    mg = mockgun.Shotgun("http://random_url")
    project = mg.create(
        "Project",
        {
            "code": "test",
            "name": "test_project",
            "sg_ayon_auto_sync": True,
        }
    )
    return mg, project