KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue23023_http_fields.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <tuple>
#include <wx/arrstr.h>
#include <json_common.h>
#include <http_lib/http_lib_connection.h>
#include <http_lib/http_lib_settings.h>

Go to the source code of this file.

Functions

static const HTTP_LIB_PART::field_typefindField (const HTTP_LIB_PART &aPart, const std::string &aName)
 Issue #23023.
 
 BOOST_AUTO_TEST_CASE (DetailRecordPopulatesFields)
 A detail record with a fields object populates every field and reports itself as detailed.
 
 BOOST_AUTO_TEST_CASE (ListingRecordReportsNotDetailed)
 A minimal category-listing record carries no fields, so the parser reports "not detailed" and the enumeration back-fill is triggered.
 
 BOOST_AUTO_TEST_CASE (NativeBooleanFlagsAreAccepted)
 Exclusion flags and field visibility encoded as native JSON booleans must parse the same as their string equivalents rather than throwing and aborting the whole category.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( DetailRecordPopulatesFields )

A detail record with a fields object populates every field and reports itself as detailed.

Definition at line 61 of file test_issue23023_http_fields.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), HTTP_LIB_PART::exclude_from_bom, HTTP_LIB_PART::exclude_from_sim, HTTP_LIB_PART::fields, findField(), setPartExtendedData(), and HTTP_LIB_PART::symbolIdStr.

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( ListingRecordReportsNotDetailed )

A minimal category-listing record carries no fields, so the parser reports "not detailed" and the enumeration back-fill is triggered.

This is the exact condition of the bug.

Definition at line 104 of file test_issue23023_http_fields.cpp.

References HTTP_LIB_PART::fields, and setPartExtendedData().

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( NativeBooleanFlagsAreAccepted )

Exclusion flags and field visibility encoded as native JSON booleans must parse the same as their string equivalents rather than throwing and aborting the whole category.

Definition at line 121 of file test_issue23023_http_fields.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), HTTP_LIB_PART::exclude_from_bom, findField(), and setPartExtendedData().

◆ findField()

static const HTTP_LIB_PART::field_type * findField ( const HTTP_LIB_PART & aPart,
const std::string & aName )
static

Issue #23023.

HTTP library fields content was missing in the symbol chooser.

The category listing returns only minimal part data, so fields were absent until a part was selected individually. setPartExtendedData() is the shared parser that pulls the field content (and exclusion flags) out of a part's JSON record; it must populate every field the record carries and report whether the record contained the detailed field set, which drives the per-part back-fill fetch during enumeration.

The JSON below is the recorded RC0603FR-0710KL detail response from the KiCad HTTP test server fixture (qa/tests/eeschema/http_lib_test_server.py).

Definition at line 48 of file test_issue23023_http_fields.cpp.

References findField(), and name.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateTitleBlock(), and findField().