def test_add(self): slims = Slims("testSlims", "http://localhost:9999", "admin", "admin") responses.add( responses.PUT, 'http://localhost:9999/rest/Content', json={"entities": [{ "pk": 1, "tableName": "Content", "columns": [] }]}, content_type='application/json', ) added = slims.add("Content", {"test": "foo"}) self.assertIsInstance(added, Record)
dna_type = slims.fetch("ContentType", equals("cntp_name", "DNA")) if not dna_type: sys.exit("No DNA Content type found, can not continue") # Fetch Building Test location (ideally with location type Building, # but this is not mandatory) locations = slims.fetch("Location", equals("lctn_name", "Building Test")) if not locations: sys.exit("No location called Building Test found, can not continue") print("Creating DNA Record...") created_dna = slims.add( "Content", { 'cntn_fk_contentType': dna_type[0].pk(), 'cntn_status': Status.AVAILABLE.value, 'cntn_fk_location': locations[0].pk() }) print("Content with status", created_dna.cntn_status.displayValue, ", location", created_dna.cntn_fk_location.displayValue, "and type", created_dna.cntn_fk_contentType.displayValue, "has been created.\n\n") # Example N_2: Creating another content record. Requires a content type "fish" # for which "Use barcode as ID" is set to false. # Fetch fish content type print("Example 2") fish_type = slims.fetch("ContentType", equals("cntp_name", "fish")) if not fish_type: sys.exit("No fish Content type found, can not continue")