def test_stock(self): s = stock.StockItem.list(self.api, part=1) self.assertEqual(len(s), 2) s = part.Part(self.api, 1).getStockItems() self.assertEqual(len(s), 2)
def test_get_widget(self): widget = part.Part(self.api, 8) self.assertEqual(widget.IPN, "W001") test_templates = widget.getTestTemplates() self.assertEqual(len(test_templates), 3) keys = [test.key for test in test_templates] self.assertIn('firmware', keys) self.assertIn('weight', keys) self.assertIn('paint', keys)
def test_get_widget(self): widget = part.Part(self.api, 10000) self.assertEqual(widget.name, "Chair Template") test_templates = widget.getTestTemplates() self.assertGreaterEqual(len(test_templates), 5) keys = [test.key for test in test_templates] self.assertIn('teststrengthofchair', keys) self.assertIn('applypaint', keys) self.assertIn('attachlegs', keys)
def test_stock(self): items = StockItem.list(self.api, part=1) n = len(items) self.assertGreaterEqual(n, 2) for item in items: self.assertEqual(item.part, 1) # Request via the Part instance (results should be the same!) items = part.Part(self.api, 1).getStockItems() self.assertEqual(len(items), n)
def test_add_template(self): """ Test that we can add a test template via the API """ widget = part.Part(self.api, pk=10000) n = len(widget.getTestTemplates()) part.PartTestTemplate.create( self.api, { 'part': widget.pk, 'test_name': f"Test_Name_{n}", 'description': 'A test or something', 'required': True, }) self.assertEqual(len(widget.getTestTemplates()), n + 1)