mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-07-27 03:31:35 +00:00
Import: document EDA/KiCad columns, test both column forms, fix eda_invisible inversion (#1436)
- Document the eda_* import columns in docs/usage/import_export.md: the flat form and its short aliases, and the nested eda_info.* form used by the CSV/JSON export and the shipped part_import_example.csv. - Add EntityImporterTest coverage locking in that BOTH the nested eda_info.* form and the flat form import the EDA fields correctly (the nested form already worked via the serializer but was untested, so an export -> re-import round-trip could silently regress). - Fix the eda_invisible alias: it was a plain key-rename to eda_visibility, so eda_invisible=1 stored visibility=true (made the part visible - the opposite of the name). It is now handled explicitly and inverted.
This commit is contained in:
parent
12b53f15ba
commit
3998248905
3 changed files with 99 additions and 1 deletions
|
|
@ -350,6 +350,84 @@ EOT;
|
|||
$this->assertSame('test,test2', $results[0]->getTags());
|
||||
}
|
||||
|
||||
public function testImportAcceptsNestedEdaInfoColumns(): void
|
||||
{
|
||||
//The API / JSON export writes EDA columns as "eda_info.kicad_symbol"; re-importing such a
|
||||
//file must fill the EDA fields (previously these columns were silently dropped).
|
||||
$input = "name;eda_info.kicad_symbol;eda_info.kicad_footprint;eda_info.reference_prefix;eda_info.value\n"
|
||||
."Nested EDA part;Device:L;Inductor_THT:L_Axial_0307;L;100uH";
|
||||
|
||||
$category = new Category();
|
||||
$category->setName('Test EDA category');
|
||||
|
||||
$errors = [];
|
||||
$results = $this->service->importString($input, [
|
||||
'class' => Part::class,
|
||||
'format' => 'csv',
|
||||
'csv_delimiter' => ';',
|
||||
'create_unknown_datastructures' => true,
|
||||
'part_category' => $category,
|
||||
], $errors);
|
||||
|
||||
$this->assertCount(1, $results);
|
||||
$this->assertEmpty($errors);
|
||||
$eda = $results[0]->getEdaInfo();
|
||||
$this->assertSame('Device:L', $eda->getKicadSymbol());
|
||||
$this->assertSame('Inductor_THT:L_Axial_0307', $eda->getKicadFootprint());
|
||||
$this->assertSame('L', $eda->getReferencePrefix());
|
||||
$this->assertSame('100uH', $eda->getValue());
|
||||
}
|
||||
|
||||
public function testImportAcceptsFlatEdaColumns(): void
|
||||
{
|
||||
//The documented flat form (and its short aliases) must keep working.
|
||||
$input = "name;eda_kicad_symbol;kicad_footprint;kicad_reference\n"
|
||||
."Flat EDA part;Device:R;Resistor_SMD:R_0805_2012Metric;R";
|
||||
|
||||
$category = new Category();
|
||||
$category->setName('Test EDA category');
|
||||
|
||||
$errors = [];
|
||||
$results = $this->service->importString($input, [
|
||||
'class' => Part::class,
|
||||
'format' => 'csv',
|
||||
'csv_delimiter' => ';',
|
||||
'create_unknown_datastructures' => true,
|
||||
'part_category' => $category,
|
||||
], $errors);
|
||||
|
||||
$this->assertCount(1, $results);
|
||||
$this->assertEmpty($errors);
|
||||
$eda = $results[0]->getEdaInfo();
|
||||
$this->assertSame('Device:R', $eda->getKicadSymbol());
|
||||
$this->assertSame('Resistor_SMD:R_0805_2012Metric', $eda->getKicadFootprint());
|
||||
$this->assertSame('R', $eda->getReferencePrefix());
|
||||
}
|
||||
|
||||
public function testImportInvisibleAliasInvertsVisibility(): void
|
||||
{
|
||||
//"eda_invisible" is the inverse convenience alias of "eda_visibility": eda_invisible=1
|
||||
//must make the part NOT visible to the EDA tool (visibility=false), not visible.
|
||||
$input = "name;eda_invisible\n"
|
||||
."Hidden EDA part;1";
|
||||
|
||||
$category = new Category();
|
||||
$category->setName('Test EDA category');
|
||||
|
||||
$errors = [];
|
||||
$results = $this->service->importString($input, [
|
||||
'class' => Part::class,
|
||||
'format' => 'csv',
|
||||
'csv_delimiter' => ';',
|
||||
'create_unknown_datastructures' => true,
|
||||
'part_category' => $category,
|
||||
], $errors);
|
||||
|
||||
$this->assertCount(1, $results);
|
||||
$this->assertEmpty($errors);
|
||||
$this->assertFalse($results[0]->getEdaInfo()->getVisibility());
|
||||
}
|
||||
|
||||
public function testImportExcelFileProjects(): void
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue