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_not_Commited(mock_send, mock_load, mock_exists, status):
    """Do nothing if not created."""
    mock_exists.return_value = False
    vf = Vf()
    vf._status = status
    vf.submit()
    mock_send.assert_not_called()
Example #3
0
def test__deep_load_response_OK_under_cert(mock_send, mock_created):
    mock_created.return_value = True
    vf = Vf()
    vf.identifier = "5689"
    vf._version = "4567"
    vf._status = const.UNDER_CERTIFICATION
    mock_send.return_value = {
        'resources': [{
            'uuid':
            '5689',
            'name':
            'test',
            'uniqueId':
            '71011',
            'categories': [{
                'name': 'test',
                'subcategories': [{
                    'name': 'test_subcategory'
                }]
            }]
        }]
    }
    vf.deep_load()
    assert vf.unique_identifier == "71011"
    assert vf._category_name == "test"
    assert vf._subcategory_name == "test_subcategory"
    mock_send.assert_called_once_with(
        'GET',
        'Deep Load Vf',
        "{}/sdc1/feProxy/rest/v1/screen?excludeTypes=VFCMT&excludeTypes=Configuration"
        .format(vf.base_front_url),
        headers=headers_sdc_tester(vf.headers))
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)
Example #5
0
def test__deep_load_no_response(mock_send, mock_created):
    mock_created.return_value = True
    vf = Vf()
    vf.identifier = "1234"
    vf._version = "4567"
    vf._status = const.CHECKED_IN
    mock_send.return_value = {}
    vf.deep_load()
    assert vf._unique_identifier is None
    mock_send.assert_called_once_with(
        'GET',
        'Deep Load Vf',
        "{}/sdc1/feProxy/rest/v1/screen?excludeTypes=VFCMT&excludeTypes=Configuration"
        .format(vf.base_front_url),
        headers=headers_sdc_creator(vf.headers))
Example #6
0
def test__deep_load_response_NOK(mock_send, mock_created):
    mock_created.return_value = True
    vf = Vf()
    vf.identifier = "5678"
    vf._version = "4567"
    vf._status = const.CHECKED_IN
    mock_send.return_value = {
        'resources': [{
            'uuid': '5689',
            'name': 'test',
            'uniqueId': '71011'
        }]
    }
    vf.deep_load()
    assert vf._unique_identifier is None
    mock_send.assert_called_once_with(
        'GET',
        'Deep Load Vf',
        "{}/sdc1/feProxy/rest/v1/screen?excludeTypes=VFCMT&excludeTypes=Configuration"
        .format(vf.base_front_url),
        headers=headers_sdc_creator(vf.headers))