From 1ca7c2843b3fd7ea5756b570b7a554b6d4ef656f Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Mon, 8 Aug 2011 15:35:41 -0700 Subject: [PATCH] Deal with (failed) in flowcell names. Create a test case that triggers it and use '__startswith' to work around the name. --- .../inventory/fixtures/test_harddisks.json | 65 ++++++++++++++++++- htsworkflow/frontend/inventory/tests.py | 25 +++++++ htsworkflow/frontend/inventory/views.py | 2 +- 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/htsworkflow/frontend/inventory/fixtures/test_harddisks.json b/htsworkflow/frontend/inventory/fixtures/test_harddisks.json index feb2090..7ca5b0c 100644 --- a/htsworkflow/frontend/inventory/fixtures/test_harddisks.json +++ b/htsworkflow/frontend/inventory/fixtures/test_harddisks.json @@ -163,7 +163,7 @@ "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", @@ -174,6 +174,17 @@ "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, @@ -334,5 +345,55 @@ "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 +] diff --git a/htsworkflow/frontend/inventory/tests.py b/htsworkflow/frontend/inventory/tests.py index 01b9b21..0e67546 100644 --- a/htsworkflow/frontend/inventory/tests.py +++ b/htsworkflow/frontend/inventory/tests.py @@ -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() diff --git a/htsworkflow/frontend/inventory/views.py b/htsworkflow/frontend/inventory/views.py index 1510180..1fb7378 100644 --- a/htsworkflow/frontend/inventory/views.py +++ b/htsworkflow/frontend/inventory/views.py @@ -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) -- 2.30.2