Deal with (failed) in flowcell names.
authorDiane Trout <diane@caltech.edu>
Mon, 8 Aug 2011 22:35:41 +0000 (15:35 -0700)
committerDiane Trout <diane@caltech.edu>
Mon, 8 Aug 2011 22:35:41 +0000 (15:35 -0700)
Create a test case that triggers it and use '__startswith' to
work around the name.

htsworkflow/frontend/inventory/fixtures/test_harddisks.json
htsworkflow/frontend/inventory/tests.py
htsworkflow/frontend/inventory/views.py

index feb2090b0ef5dec1600b5520a8d8430766c549c5..7ca5b0cbee2c680bd69579683b9d2c802e7ee108 100644 (file)
       "flowcell_id": "11ONEAAXX"
       }
   }, 
- {"pk": 2, "model": "experiments.flowcell", 
 {"pk": 2, "model": "experiments.flowcell", 
   "fields": {
       "paired_end": false, 
       "run_date": "2010-09-11 22:12:13", 
       "flowcell_id": "22TWOAAXX"
       }
   }, 
+  {"pk": 3, "model": "experiments.flowcell", 
+  "fields": {
+      "paired_end": false, 
+      "run_date": "2010-09-11 22:12:13", 
+      "read_length": 75, 
+      "notes": "",
+      "advanced_run": false,
+      "control_lane": 2,
+      "flowcell_id": "33THRAAXX (failed)"
+      }
+  }, 
   {"pk": "10001", "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
        "lane_number": 8,
        "pM": "8"
        }
+   },
+  {"pk": 9, "model": "experiments.lane",
+   "fields": {
+       "comment": "10004 lane 4",
+       "library": "10001",
+       "cluster_estimate": 100000,
+       "flowcell": 3,
+       "lane_number": 4,
+       "pM": "8"
+       }
+   }, 
+  {"pk": 10, "model": "experiments.lane",
+   "fields": {
+       "comment": "10001 lane 1",
+       "library": "10001",
+       "cluster_estimate": 100000,
+       "flowcell": 3,
+       "lane_number": 1,
+       "pM": "8"
+       }
+   }, 
+  {"pk": 11, "model": "experiments.lane",
+   "fields": {
+       "comment": "10001 lane 1",
+       "library": "10003",
+       "cluster_estimate": 100000,
+       "flowcell": 3,
+       "lane_number": 2,
+       "pM": "8"
+       }
+   }, 
+  {"pk": 12, "model": "experiments.lane",
+   "fields": {
+       "comment": "10003 lane 8",
+       "library": "10003",
+       "cluster_estimate": 100000,
+       "flowcell": 3,
+       "lane_number": 8,
+       "pM": "8"
+       }
+   }, 
+  {"pk": 13, "model": "experiments.lane",
+   "fields": {
+       "comment": "10002 lane 8",
+       "library": "10001",
+       "cluster_estimate": 100000,
+       "flowcell": 3,
+       "lane_number": 8,
+       "pM": "8"
+       }
    }
-]
\ No newline at end of file
+]
index 01b9b2105d4094ad44caf39807bf6a0fe46d5e31..0e6754649a419f32d61dd92a1531fecdf519f600 100644 (file)
@@ -72,6 +72,31 @@ class InventoryTestCase(TestCase):
         self.failUnlessEqual('http://localhost/flowcell/%s/' % (flowcell),
                              flowcells[0])
 
+    def test_add_disk_failed_flowcell(self):
+        url = '/inventory/it/Hard Drive/'
+        #url_disk = '/inventory/8a90b6ce522311de99b00015172ce556/'
+        url_disk = '/inventory/b0792d425aa411de99b00015172ce556/'
+        indexNode = localhostNode(url)
+        diskNode = localhostNode(url_disk)
+        self.client.login(username='test', password='BJOKL5kAj6aFZ6A5')
+
+        flowcells = self.get_flowcells_from_content(url, indexNode, diskNode)
+        self.failUnlessEqual(len(flowcells), 0)
+
+        # step two link the flowcell
+        flowcell = '33THRAAXX'
+        serial = 'WCAU49042470'
+        link_url = urlresolvers.reverse(
+                'htsworkflow.frontend.inventory.views.link_flowcell_and_device',
+                args=(flowcell, serial))
+        link_response = self.client.get(link_url)
+        self.failUnlessEqual(link_response.status_code, 200)
+
+        flowcells = self.get_flowcells_from_content(url, indexNode, diskNode)
+        self.failUnlessEqual(len(flowcells), 1)
+        self.failUnlessEqual('http://localhost/flowcell/%s/' % (flowcell),
+                             flowcells[0])
+
         
     def get_flowcells_from_content(self, url, rootNode, diskNode):
         model = get_model()
index 15101804d93e8feadc7cbdd35dd7234622ec6dd0..1fb73783c029b4434614f6c8d7d761f36caab026 100644 (file)
@@ -321,7 +321,7 @@ def link_flowcell_and_device(request, flowcell, serial):
     ###########################################
     # Retrieve FlowCell
     try:
-        fc = FlowCell.objects.get(flowcell_id=flowcell)
+        fc = FlowCell.objects.get(flowcell_id__startswith=flowcell)
     except ObjectDoesNotExist, e:
         msg = "FlowCell with flowcell_id of %s not found." % (flowcell)
         raise ObjectDoesNotExist(msg)