def test_add_properties(mock_send_message_json):
    vf = Vf(name="test")
    vf._identifier = "toto"
    vf._unique_identifier = "toto"
    vf._status = const.CERTIFIED
    with pytest.raises(StatusError):
        vf.add_property(Property(name="test", property_type="string"))
    vf._status = const.DRAFT
    vf.add_property(Property(name="test", property_type="string"))
    mock_send_message_json.assert_called_once()
def test_submit_OK(mock_send, mock_load, mock_exists):
    """Don't update status if submission NOK."""
    mock_exists.return_value = True
    vf = Vf()
    vf._status = const.COMMITED
    expected_data = '{\n  "userRemarks": "certify"\n}'
    vf._version = "1234"
    vf._unique_identifier = "12345"
    vf.submit()
    mock_send.assert_called_once_with(
        "POST",
        "Certify Vf",
        'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/rest/v1/catalog/resources/12345/lifecycleState/Certify',
        data=expected_data)
def test_update_vsp(mock_send):

    vf = Vf(name="test")
    vf._unique_identifier = "123"
    vsp = MagicMock()
    vsp.csar_uuid = "122333"
    vsp.human_readable_version = "1.0"
    mock_send.return_value = {
        "csarUUID": "322111",
        "csarVersion": "0.1",
        "tags": [],
        "categories": [],
        "allVersions": [],
        "archived": False,
        "creationDate": int(time.time()),
        "lastUpdateDate": int(time.time()),
    }
    vf.update_vsp(vsp)
    assert mock_send.call_count == 2
    mock_call_kwargs_data = json.loads(
        mock_send.mock_calls[-1][2]
        ["data"])  # Get kward from `unittest.mock.call` tuple
    assert mock_call_kwargs_data["csarUUID"] == "122333"
    assert mock_call_kwargs_data["csarVersion"] == "1.0"
Esempio n. 4
0
def test__unique_identifier_no_load(mock_load):
    vf = Vf()
    vf.identifier = "1234"
    vf._unique_identifier = "toto"
    assert vf.unique_identifier == "toto"
    mock_load.assert_not_called()