コード例 #1
0
def test_vendor_unknown():
    """Integration tests for Vendor."""
    response = requests.post("{}/reset".format(SDC.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.create()
    assert vendor.created()
    vendor.submit()
    assert vendor.status == const.CERTIFIED
コード例 #2
0
def test_create_issue_in_creation(mock_send, mock_exists):
    """Do nothing if not created but issue during creation."""
    vendor = Vendor()
    expected_data = '{\n  "iconRef": "icon",\n  "vendorName": "Generic-Vendor",\n  "description": "vendor"\n}'
    mock_exists.return_value = False
    mock_send.return_value = {}
    vendor.create()
    mock_send.assert_called_once_with("POST",
                                      "create Vendor",
                                      mock.ANY,
                                      data=expected_data)
    assert vendor.created() == False
コード例 #3
0
def test_create_OK(mock_send, mock_exists):
    """Create and update object."""
    vendor = Vendor()
    expected_data = '{\n  "iconRef": "icon",\n  "vendorName": "Generic-Vendor",\n  "description": "vendor"\n}'
    mock_exists.return_value = False
    mock_send.return_value = {
        'itemId': "1234",
        'version': {
            'id': "5678",
            'status': 'state_created'
        }
    }
    vendor.create()
    mock_send.assert_called_once_with("POST",
                                      "create Vendor",
                                      mock.ANY,
                                      data=expected_data)
    assert vendor.status == const.DRAFT
    assert vendor.identifier == "1234"
    assert vendor.version == "5678"
コード例 #4
0
def test_create_already_exists(mock_send, mock_exists):
    """Do nothing if already created in SDC."""
    vendor = Vendor()
    mock_exists.return_value = True
    vendor.create()
    mock_send.assert_not_called()