コード例 #1
0
def test_software_system_instance_tags(model_with_system):
    """Check default tags."""
    node = SoftwareSystemInstance(
        software_system=model_with_system.mock_system, instance_id="9"
    )
    assert Tags.ELEMENT in node.tags
    assert Tags.SOFTWARE_SYSTEM_INSTANCE in node.tags
コード例 #2
0
def test_software_system_instance_name_is_software_system_name(model_with_system):
    """Ensure software_system instance takes its name from its software system."""
    io = SoftwareSystemInstanceIO(
        software_system_id="19", instance_id=3, environment="Live"
    )

    instance = SoftwareSystemInstance.hydrate(io, model_with_system, parent=None)

    assert instance.name == "Mock System"
コード例 #3
0
def test_software_system_instance_hydration_retrieves_software_system_from_id(
    model_with_system,
):
    """Check that the software_system instance is retrieved on hydration."""
    io = SoftwareSystemInstanceIO(
        software_system_id="19", instance_id=3, environment="Live"
    )

    instance = SoftwareSystemInstance.hydrate(io, model_with_system, parent=None)

    assert instance.instance_id == 3
    assert instance.environment == "Live"
    assert instance.software_system is model_with_system.mock_system
    assert instance.software_system_id == "19"
コード例 #4
0
def test_software_system_instance_hyrdates_http_health_checks(model_with_system):
    """Check that health checks are hydrated into the SoftwareSystemInstance."""
    health_check_io = HTTPHealthCheckIO(name="name", url="http://a.b.com")
    io = SoftwareSystemInstanceIO(
        software_system_id="19",
        instance_id=3,
        environment="Live",
        health_checks=[health_check_io],
    )

    instance = SoftwareSystemInstance.hydrate(io, model_with_system, parent=None)

    assert len(instance.health_checks) == 1
    assert list(instance.health_checks)[0].name == "name"
コード例 #5
0
def test_software_system_instance_serialization(model_with_system):
    """Test that system instances serialise properly."""
    health_check = HTTPHealthCheck(name="health", url="http://a.b.com")
    instance = SoftwareSystemInstance(
        software_system=model_with_system.mock_system,
        instance_id=7,
        health_checks=[health_check],
    )

    io = SoftwareSystemInstanceIO.from_orm(instance)

    assert io.software_system_id == "19"
    assert io.instance_id == 7
    assert len(io.health_checks) == 1
    assert io.health_checks[0].name == "health"
コード例 #6
0
def test_software_system_instance_init(attributes):
    """Expect proper initialization from arguments."""
    instance = SoftwareSystemInstance(**attributes)
    for attr, expected in attributes.items():
        assert getattr(instance, attr) == expected
コード例 #7
0
 def __iadd__(self, instance: SoftwareSystemInstance):
     """Simulate the model assigning IDs to new elements."""
     if not instance.id:
         instance.id = "id"
     instance.set_model(self)
     return self