Esempio n. 1
0
    def test_filter_value(self):

        for i in range(0, len(self.test_files)):
            # filter all 100n capacitors
            Out.test('Counting matches of value=100n')
            self.test_filter.add_constraint('Value', '100n')
            matching = self.test_schematics[i].filter_components(self.test_filter)
            assert(len(matching) == self.matching_100n[i])
Esempio n. 2
0
 def test_merge(self):
     target_component = Component(self.input_data[2])
     source_component = Component(self.input_data[1])
     target_component.merge(source_component)
     assert(target_component.get_field('Value').value == '100M')
     assert(target_component.get_field('Value')._x_pos == 3750)
     assert(target_component.get_field('Supplier').value == 'Mouser')
     assert(target_component.get_field('Supplier')._x_pos == 3750)
     Out.test(target_component.serialize())
Esempio n. 3
0
    def test_filter_value_and_footprint(self):

        for i in range(0, len(self.test_files)):
            # filter all 100n capacitors with a certain footprint
            Out.test('Counting matches of value=100n and footprint=Capacitors_SMD:C_0603')
            self.test_filter.add_constraint('Value', '100n')
            self.test_filter.add_constraint('Footprint', 'Capacitors_SMD:C_0603')
            matching = self.test_schematics[i].filter_components(self.test_filter)
            assert(len(matching) == self.matching_100n_0603[i])
Esempio n. 4
0
    def setUp(self):
        self.test_schematics = []
        self.serialized_schematics = []
        self.test_files = ['test1.sch', 'test2.sch', 'test3.sch', 'test4.sch']
        self.matching_100n = [2,9,1,0]
        self.matching_100n_0603 = [2,0,0,0]

        # init and serialize all schematics
        for i in range(0, len(self.test_files)):
            test_file = self.test_files[i]
            Out.test('Initialize and serialize schematic file ' + test_file + ' ...')
            self.test_schematics.append(Schematic(test_file))
            self.serialized_schematics.append(self.test_schematics[i].serialize())


        # init filter
        self.test_filter = Filter()