def test_create_pv_nodes_fail(mock_bg, mock_gp): """Test CVEPut.create_pv_nodes() fail.""" mock_gp.return_value = 'query' mock_bg.return_value = (False, {'error': 'something happened'}) cve = CVEPut(valid_put_input) nodes, successfull_create, aff = cve.create_pv_nodes() assert len(nodes) == 0 assert successfull_create is False
def test_create_pv_nodes(mock_bg, mock_gp): """Test CVEPut.create_pv_nodes().""" mock_gp.return_value = 'query' mock_bg.return_value = True, {} cve = CVEPut(valid_put_input) nodes, successfull_create = cve.create_pv_nodes() assert len(nodes) == 2 assert successfull_create is True assert ('pypi', 'numpy', '10.0') in nodes assert ('pypi', 'numpy', '11.0') in nodes
def test_create_pv_nodes(mock_bg, mock_gp): """Test CVEPut.create_pv_nodes().""" mock_gp.return_value = "query pkg.property('latest_version', '1.2.3');" mock_bg.return_value = True, {} cve = CVEPut(valid_put_input) nodes, successfull_create, aff = cve.create_pv_nodes() assert len(nodes) == 2 assert successfull_create is True assert ('pypi', 'numpy', '10.0') in nodes assert ('pypi', 'numpy', '11.0') in nodes assert aff['numpy']['ecosystem'] == "pypi" assert aff['numpy']['latest_version'] == "1.2.3"