예제 #1
0
def test_equality_really_equals():
    """Check two Vendors are equals if name is the same."""
    vendor_1 = Vendor(name="equal")
    vendor_1.identifier = "1234"
    vendor_2 = Vendor(name="equal")
    vendor_2.identifier = "1235"
    assert vendor_1 == vendor_2
예제 #2
0
def test_equality_not_equals():
    """Check two Vendors are not equals if name is not the same."""
    vendor_1 = Vendor(name="equal")
    vendor_1.identifier = "1234"
    vendor_2 = Vendor(name="not_equal")
    vendor_2.identifier = "1234"
    assert vendor_1 != vendor_2
예제 #3
0
def test_status_no_load_created(mock_load, mock_created):
    mock_created.return_value = True
    vendor = Vendor()
    vendor.identifier = "12345"
    vendor._status = "Draft"
    assert vendor.status == "Draft"
    mock_load.assert_not_called()
예제 #4
0
def test_exists_exists(mock_get_all):
    """Return True if vendor exists in SDC."""
    vendor_1 = Vendor(name="one")
    vendor_1.identifier = "1234"
    mock_get_all.return_value = [vendor_1]
    vendor = Vendor(name="one")
    assert vendor.exists()
예제 #5
0
def test_exists_not_exists(mock_get_all):
    """Return False if vendor doesn't exist in SDC."""
    vendor_1 = Vendor(name="one")
    vendor_1.identifier = "1234"
    mock_get_all.return_value = [vendor_1]
    vendor = Vendor(name="two")
    assert not vendor.exists()
def test__get_items_version_details(mock_send):
    vendor = Vendor()
    vendor.identifier = "1234"
    vendor._version = "4567"
    mock_send.return_value = {'return': 'value'}
    assert vendor._get_item_version_details() == {'return': 'value'}
    mock_send.assert_called_once_with(
        'GET', 'get item version',
        "{}/items/1234/versions/4567".format(vendor._base_url()))
예제 #7
0
def test_submit_certified_OK(mock_send, mock_load, mock_exists):
    """Set status to CERTIFIED if submission OK."""
    mock_exists.return_value = True
    vendor = Vendor()
    vendor._status = "Draft"
    vendor._version = "1234"
    vendor.identifier = "12345"
    mock_send.return_value = mock.Mock()
    expected_data = '{\n\n  "action": "Submit"\n}'
    vendor.submit()
    mock_send.assert_called_once_with(
        "PUT",
        "Submit Vendor",
        'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/onboarding-api/v1.0/vendor-license-models/12345/versions/1234/actions',
        data=expected_data)
    assert vendor.status == const.CERTIFIED
예제 #8
0
def test_load_created(mock_send, mock_get_all):
    mock_send.return_value = {
        'results': [{
            'status': 'state_one',
            'id': "5678"
        }]
    }
    vendor = Vendor(name="one")
    vendor.identifier = "1234"
    vendor.load()
    mock_get_all.assert_not_called()
    mock_send.assert_called_once_with(
        'GET', 'get item',
        'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/onboarding-api/v1.0/items/1234/versions'
    )
    assert vendor.status == "state_one"
    assert vendor.version == "5678"
def test__get_items_version_details_no_version(mock_send, mock_load):
    vendor = Vendor()
    vendor.identifier = "1234"
    assert vendor._get_item_version_details() == {}
    mock_send.assert_not_called()
예제 #10
0
def test_equality_not_equals_not_same_object():
    """Check a Vendor and something different are not equals."""
    vendor_1 = Vendor(name="equal")
    vendor_1.identifier = "1234"
    vendor_2 = "equal"
    assert vendor_1 != vendor_2
예제 #11
0
def test_status_with_load(mock_load):
    vendor = Vendor()
    vendor.identifier = "12345"
    assert vendor.status == None
    mock_load.assert_called_once()
예제 #12
0
def test_version_with_load(mock_load):
    vendor = Vendor()
    vendor.identifier = "12345"
    assert vendor.version == None
    mock_load.assert_called_once()