def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.Ins = BioPlate({"id": 1}, db_name="test_plate.db", inserts=True) self.Inserts = BioPlate(4, 3, inserts=True) self.Value = {"A1": "Control", "C[2,10]": "Test1", "11[B,G]": "Test2"}
def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.stack = self.plt + self.plt1 self.stack1 = BioPlate(4, 12, 8) self.stacki = self.Ins + self.Ins1 self.stacki1 = BioPlate(4, 12, 8, inserts=True) self.Value = {"A1": "Control", "C[2,10]": "Test1", "11[B,G]": "Test2"}
def test_stack(self): pl1 = BioPlate(12, 8) pl2 = BioPlate(12, 8) pl1.set("A2", "bob") self.phi.add_hplate( Plate_id=2, numWell=96, plate_name="stack", plate_array=[pl1, pl2] ) Pl = self.phi.get_one(2, key="id").plate self.assertEqual(Pl.name, "Stack") self.assertEqual(Pl.get(0, "A2"), "bob")
def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.plt = BioPlate({"id": 1}, db_name="test_plate.db") self.plt1 = BioPlate(12, 8) self.plt3 = BioPlate(12,8) self.Value = {"A1": "Control", "C[2,10]": "Test1", "11[B,G]": "Test2"} self.multiValue = {"A[2-8]" : "Bob"} self.multiValue1 = {"A-D[1-5]" : ["A", "B", "C", "D"], "A-D[1-6]" : ["_1", "_2", "_3", "_4"]}
def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.plate1 = Array(12, 8) self.plate2 = BioPlate(12, 8) self.plate3 = BioPlate(12, 8) self.plate4 = BioPlate(12, 8) self.plate5 = BioPlate(12, 8) self.stack1 = self.plate2 + self.plate3 self.stack2 = self.plate4 + self.plate5
def test__add__(self): Nstack = self.stack + self.plt2 self.assertEqual(Nstack.name, "Stack") np.testing.assert_array_equal(Nstack[2], self.plt2) with self.assertRaises(ValueError): Nstack + self.plt2 N2stack = self.plt2 + self.plt3 Astack = self.stack + N2stack np.testing.assert_array_equal(Nstack[2], self.plt2) pp = BioPlate(12, 8) ps = BioPlate(2, 12, 8) Nps = pp + ps self.assertIs(Nps[0], pp)
def test_inserts_stack(self): ins = BioPlate(2, 12, 8, inserts=True) ins.set(0, "top", "A1", "gaston") ins1 = BioPlate(2, 12, 8, inserts=True) ins1.set(0, "bot", "A1", "gulu") ins2 = BioPlate(12, 8, inserts=True) Nins = ins + ins1 PNins = ins2 + ins self.assertEqual(Nins.get(0, "top", "A1"), "gaston") self.assertEqual(Nins.get(2, "bot", "A1"), "gulu") self.assertEqual(PNins.get(1, "top", "A1"), "gaston")
def test_add_hplate(self): add_plate_1 = self.pdb.add_plate( numWell=6, numColumns=3, numRows=2, surfWell=9.5, maxVolWell=2000, workVolWell=2000, refURL="https://csmedia2.corning.com/LifeSciences/Media/pdf/cc_surface_areas.pdf", ) p6 = self.pdb.get_one_plate(6) Plate6 = BioPlate({"numWell": 6}, db_name="test_plate.db") add_hplate_1 = self.phi.add_hplate( Plate_id=2, numWell=6, plate_name="second plate", plate_array=Plate6 ) add_hplate_2 = self.phi.add_hplate( Plate_id=2, numWell=6, plate_name="second plate", plate_array=Plate6 ) self.assertEqual( add_hplate_1, "Plate second plate with 6 wells was successfully added to database test_plate_historic.db", ) self.assertEqual(add_hplate_2, 2) self.assertEqual( f"<plate N°2: second plate, 6 wells, {self.phi.date_now}>", str(self.phi.get_one_hplate(6)), ) self.assertEqual(6, self.phi.get_hplate(numWell=6)[0].numWell)
def setUpClass(cls): """ This function is run one time at the beginning of tests :return: """ cls.pdb = PlateDB(db_name="test_plate.db") cls.pdb.add_plate( numWell=96, numColumns=12, numRows=8, surfWell=0.29, maxVolWell=200, workVolWell=200, refURL="https://csmedia2.corning.com/LifeSciences/Media/pdf/cc_surface_areas.pdf", ) v = { "A[2,8]": "VC", "H[2,8]": "MS", "1-4[B,G]": ["MLR", "NT", "1.1", "1.2"], "E-G[8,10]": ["Val1", "Val2", "Val3"], } cls.plt = BioPlate({"id": 1}, db_name="test_plate.db") cls.plt.set(v) cls.phi = PlateHist(db_name="test_plate_historic.db") cls.phi.add_hplate( Plate_id=1, numWell=96, plate_name="First plate to test", plate_array=cls.plt, ) dt = datetime.datetime.now() cls.date = datetime.date(dt.year, dt.month, dt.day)
def test_count(self): ValIn = {"A1": "Control", "C[2,4]": "Test1"} multi = BioPlate(2, 12, 8) multi.set(0, self.Value) multi.set(1, self.Value) multiinserts = BioPlate(2, 4, 3, inserts=True) multiinserts.set(0, "top", ValIn) self.assertEqual( multi.count(), { 0: { "": 80, "Control": 1, "Test1": 9, "Test2": 6 }, 1: { "": 80, "Control": 1, "Test1": 9, "Test2": 6 }, }, ) self.assertEqual( multiinserts.count(), { 0: { "top": { "Control": 1, "Test1": 3, "": 8 }, "bot": { "": 12 } }, 1: { "top": { "": 12 }, "bot": { "": 12 } }, }, )
def test_multi_value(self): pl = BioPlate(12,8) pl.set(self.multiValue) self.assertEqual(pl["A[2-8]"].tolist(), ["Bob"] * 7) pl1 = BioPlate(12,8) pl1.set(self.multiValue1, merge=True) self.assertEqual(pl1["A-D[1-5]"].tolist(), [ ["A_1"] * 5, ["B_2"] * 5, ["C_3"] *5, ["D_4"] *5 ])
def test_merge(self): ins = BioPlate(12, 8, inserts=True) ins.top.set("2-5[A-C]", ["test", "tes", "te", "t"]) self.assertEqual(ins.top.get("A2"), "test") ins.top.set("2-3[A-C]", ["_1", "_2"], merge=True) ins.top.set("A-C[4-5]", ["_3", "_4", "_5"], merge=True) self.assertEqual(ins.top.get("A2"), "test_1") self.assertEqual(ins.top.get("B3"), "tes_2") self.assertEqual(ins.top.get("A4"), "te_3") self.assertEqual(ins.top.get("B5"), "t_4") self.assertEqual(ins.top.get("C5"), "t_5")
def setUpClass(cls): """ This function is run one time at the beginning of tests :return: """ v = { "A[2,8]": "VC", "H[2,8]": "MS", "1-4[B,G]": ["MLR", "NT", "1.1", "1.2"], "E-G[8,10]": ["Val1", "Val2", "Val3"], } v1 = { "A[2,8]": "VC1", "H[2,8]": "MS1", "1-4[B,G]": ["MLR1", "NT1", "1.3", "1.4"], "E-G[8,10]": ["Val4", "Val5", "Val6"], } v2 = { "A[2,8]": "Top", "H[2,8]": "MS", "1-4[B,G]": ["MLR", "NT", "1.1", "1.2"], "E-G[8,10]": ["Val1", "Val2", "Val3"], } v3 = { "A[2,8]": "Bot", "H[2,8]": "MS1", "1-4[B,G]": ["MLR1", "NT1", "1.3", "1.4"], "E-G[8,10]": ["Val4", "Val5", "Val6"], } cls.plt = BioPlate(12, 8) cls.plt.set(v) cls.plt1 = BioPlate(12, 8) cls.plt1.set(v1) cls.stack = cls.plt + cls.plt1 cls.Inserts = BioPlate(12, 8, inserts=True) cls.Inserts.top.set(v) cls.Inserts.bot.set(v3) cls.Inserts1 = BioPlate(12, 8, inserts=True) cls.Inserts1.bot.set(v1) cls.Inserts1.top.set(v2) cls.stacki = cls.Inserts + cls.Inserts1
def test_insert_set_get(self): ii = BioPlate(12, 8, inserts=True) ii["top", "A[3-7]"] = "Bob" ii["bot", "B-D[6-9]"] = ["t1", "t2", "t3"] ii[0, "7-10[F-H]"] = ["t4", "t5", "t6", "t7"] self.assertEqual(ii.top.get("A4"), "Bob") self.assertEqual(ii.bot.get("C7"), "t2") self.assertEqual(ii.top.get("G8"), "t5") self.assertEqual(ii["top", "A5"], "Bob") self.assertEqual(ii["bot", "B6"], "t1") self.assertEqual(ii[0, "H10"], "t7") self.assertEqual(ii[1, 3, 8], "t2")
def setUpClass(cls): """ This function is run one time at the beginning of tests :return: """ cls.plt = BioPlate(12, 8) cls.plt.set("A1", "test") cls.plt1 = BioPlate(12, 8) cls.plt1.set("A1", "test1") cls.plt2 = BioPlate(12, 8) cls.plt2.set("A1", "plt2") cls.plt3 = BioPlate(12, 8) cls.plt3.set("A1", "plt3") cls.Ins = BioPlate(12, 8, inserts=True) cls.Ins.top.set("A1", "topIns") cls.Ins1 = BioPlate(12, 8, inserts=True) cls.Ins1.top.set("A1", "topIns1") cls.pdb = PlateDB(db_name="test_plate.db") cls.pdb.add_plate( numWell=96, numColumns=12, numRows=8, surfWell=0.29, maxVolWell=200, workVolWell=200, refURL= "https://csmedia2.corning.com/LifeSciences/Media/pdf/cc_surface_areas.pdf", )
def test_set(self): with self.assertRaises(IndexError): self.Inserts.top.set(self.Value) with self.assertRaises(ValueError): self.Inserts.bot.set("A[2-4]", ["test1", "test2", "test3", "test4"]) np.testing.assert_array_equal( self.Inserts.top.set("A-C[1-3]", ["Test1", "Test2", "Test3"]), self.Inserts.top, ) Ns = BioPlate(12, 8, inserts=True) Ns["bot", "4-7[A-D]"] = ["boom1", "boom2", "boom3", "boom4"] np.testing.assert_array_equal( Ns["bot", "4-7[A-D]"], np.array([["boom1", "boom2", "boom3", "boom4"], ["boom1", "boom2", "boom3", "boom4"], ["boom1", "boom2", "boom3", "boom4"], ["boom1", "boom2", "boom3", "boom4"]]))
def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.plt = BioPlate(12, 8) self.plt1 = BioPlate(12, 8) self.stack = self.plt + self.plt1 self.Inserts = BioPlate(12, 8, inserts=True) self.Inserts1 = BioPlate(12, 8, inserts=True) self.stacki = self.Inserts + self.Inserts1 self.Value = {"A1": "Control", "C[2,10]": "Test1", "11[B,G]": "Test2"} self.Value2 = {"A1": "Control1", "D[2,9]": "Test3", "12[B,H]": "Test4"} def test_reverse(self): pass
def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.PTE = BioPlateToExcel("test.xlsx") v = { "A[2,8]": "VC", "H[2,8]": "MS", "1-4[B,G]": ["MLR", "NT", "1.1", "1.2"], "E-G[8,10]": ["Val1", "Val2", "Val3"], } v1 = { "A[2,8]": "VC1", "H[2,8]": "MS1", "1-4[B,G]": ["MLR1", "NT1", "1.3", "1.4"], "E-G[8,10]": ["Val4", "Val5", "Val6"], } v2 = { "A[2,8]": "Top", "H[2,8]": "MS", "1-4[B,G]": ["MLR", "NT", "1.1", "1.2"], "E-G[8,10]": ["Val1", "Val2", "Val3"], } v3 = { "A[2,8]": "Bot", "H[2,8]": "MS1", "1-4[B,G]": ["MLR1", "NT1", "1.3", "1.4"], "E-G[8,10]": ["Val4", "Val5", "Val6"], } self.plt = BioPlate({"id": 1}, db_name="test_plate.db") self.plt.set(v) self.plt1 = BioPlate(12, 8) self.plt1.set(v1) self.stack = self.plt + self.plt1 self.Inserts = BioPlate(12, 8, inserts=True) self.Inserts.top.set(v) self.Inserts.bot.set(v3) self.Inserts1 = BioPlate(12, 8, inserts=True) self.Inserts1.bot.set(v1) self.Inserts1.top.set(v2) self.stacki = self.Inserts + self.Inserts1
def test_set_get_item(self): p = BioPlate(12,8) p["A[4-6]"] = "bob" self.assertEqual(p["A6"], "bob")
class TestPlate(unittest.TestCase): @classmethod def setUpClass(cls): """ This function is run one time at the beginning of tests :return: """ cls.pdb = PlateDB(db_name="test_plate.db") cls.pdb.add_plate( numWell=96, numColumns=12, numRows=8, surfWell=0.29, maxVolWell=200, workVolWell=200, refURL="https://csmedia2.corning.com/LifeSciences/Media/pdf/cc_surface_areas.pdf", ) @classmethod def tearDownClass(cls): """ This function is run one time at the end of tests :return: """ with contextlib.suppress(FileNotFoundError): Path( PurePath( Path(__file__).parent.parent, "BioPlate/database/DBFiles", "test_plate.db", ) ).unlink() Path( PurePath( Path(__file__).parent.parent, "BioPlate/database/DBFiles", "test_plate_historic.db", ) ).unlink() Path( PurePath( Path(__file__).parent.parent, "BioPlate/database/DBFiles", "plate_historic.db", ) ).unlink() def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.plt = BioPlate({"id": 1}, db_name="test_plate.db") self.plt1 = BioPlate(12, 8) self.plt3 = BioPlate(12,8) self.Value = {"A1": "Control", "C[2,10]": "Test1", "11[B,G]": "Test2"} self.multiValue = {"A[2-8]" : "Bob"} self.multiValue1 = {"A-D[1-5]" : ["A", "B", "C", "D"], "A-D[1-6]" : ["_1", "_2", "_3", "_4"]} def tearDown(self): """ This function is run every time at the end of each test :return: """ try: Path(PurePath("test_plate_to_excel.xlsx")).unlink() Path(PurePath("test_stack_to_excel.xlsx")).unlink() except FileNotFoundError: pass def test_Plate_init(self): np.testing.assert_array_equal( self.plt, np.array( [ [ " ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", ], ["A", "", "", "", "", "", "", "", "", "", "", "", ""], ["B", "", "", "", "", "", "", "", "", "", "", "", ""], ["C", "", "", "", "", "", "", "", "", "", "", "", ""], ["D", "", "", "", "", "", "", "", "", "", "", "", ""], ["E", "", "", "", "", "", "", "", "", "", "", "", ""], ["F", "", "", "", "", "", "", "", "", "", "", "", ""], ["G", "", "", "", "", "", "", "", "", "", "", "", ""], ["H", "", "", "", "", "", "", "", "", "", "", "", ""], ], dtype="U40", ), ) np.testing.assert_array_equal( self.plt1, np.array( [ [ " ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", ], ["A", "", "", "", "", "", "", "", "", "", "", "", ""], ["B", "", "", "", "", "", "", "", "", "", "", "", ""], ["C", "", "", "", "", "", "", "", "", "", "", "", ""], ["D", "", "", "", "", "", "", "", "", "", "", "", ""], ["E", "", "", "", "", "", "", "", "", "", "", "", ""], ["F", "", "", "", "", "", "", "", "", "", "", "", ""], ["G", "", "", "", "", "", "", "", "", "", "", "", ""], ["H", "", "", "", "", "", "", "", "", "", "", "", ""], ], dtype="U40", ), ) def test_add_value(self): """ Test add value on BioPlate from db and BioPlate generated on fly """ np.testing.assert_array_equal(self.plt.set("B2", "Test"), self.plt) np.testing.assert_array_equal(self.plt.set("A2", "Test"), self.plt) np.testing.assert_array_equal(self.plt.set("H6", "Test"), self.plt) np.testing.assert_array_equal(self.plt.set("12C", "Test"), self.plt) np.testing.assert_array_equal( self.plt.set("E8", "Test"), np.array( [ [ " ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", ], ["A", "", "Test", "", "", "", "", "", "", "", "", "", ""], ["B", "", "Test", "", "", "", "", "", "", "", "", "", ""], ["C", "", "", "", "", "", "", "", "", "", "", "", "Test"], ["D", "", "", "", "", "", "", "", "", "", "", "", ""], ["E", "", "", "", "", "", "", "", "Test", "", "", "", ""], ["F", "", "", "", "", "", "", "", "", "", "", "", ""], ["G", "", "", "", "", "", "", "", "", "", "", "", ""], ["H", "", "", "", "", "", "Test", "", "", "", "", "", ""], ], dtype="U40", ), ) np.testing.assert_array_equal(self.plt1.set("B2", "Test"), self.plt1) np.testing.assert_array_equal(self.plt1.set("A2", "Test"), self.plt1) np.testing.assert_array_equal(self.plt1.set("H6", "Test"), self.plt1) np.testing.assert_array_equal(self.plt1.set("12C", "Test"), self.plt1) def test_add_value_row(self): np.testing.assert_array_equal(self.plt.set("C[3,12]", "Test"), self.plt) np.testing.assert_array_equal(self.plt.set("A[4,3]", "Test"), self.plt) np.testing.assert_array_equal(self.plt.set("F[9,12]", "Test"), self.plt) np.testing.assert_array_equal( self.plt.set("D[6,8]", 18), np.array( [ [ " ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", ], ["A", "", "", "Test", "Test", "", "", "", "", "", "", "", ""], ["B", "", "", "", "", "", "", "", "", "", "", "", ""], [ "C", "", "", "Test", "Test", "Test", "Test", "Test", "Test", "Test", "Test", "Test", "Test", ], ["D", "", "", "", "", "", "18", "18", "18", "", "", "", ""], ["E", "", "", "", "", "", "", "", "", "", "", "", ""], [ "F", "", "", "", "", "", "", "", "", "Test", "Test", "Test", "Test", ], ["G", "", "", "", "", "", "", "", "", "", "", "", ""], ["H", "", "", "", "", "", "", "", "", "", "", "", ""], ], dtype="U40", ), ) np.testing.assert_array_equal(self.plt.set("D[1-7]", "Test"), self.plt) with self.assertRaises(ValueError) as context: self.plt.set("D[0,8]", 18) def test_add_value_column(self): np.testing.assert_array_equal(self.plt.set("3[C,E]", "Test"), self.plt) np.testing.assert_array_equal(self.plt.set("7[A,H]", "Test"), self.plt) np.testing.assert_array_equal(self.plt.set("12[F,A]", "Test"), self.plt) np.testing.assert_array_equal( self.plt.set("1[C,F]", "Test"), np.array( [ [ " ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", ], ["A", "", "", "", "", "", "", "Test", "", "", "", "", "Test"], ["B", "", "", "", "", "", "", "Test", "", "", "", "", "Test"], [ "C", "Test", "", "Test", "", "", "", "Test", "", "", "", "", "Test", ], [ "D", "Test", "", "Test", "", "", "", "Test", "", "", "", "", "Test", ], [ "E", "Test", "", "Test", "", "", "", "Test", "", "", "", "", "Test", ], ["F", "Test", "", "", "", "", "", "Test", "", "", "", "", "Test"], ["G", "", "", "", "", "", "", "Test", "", "", "", "", ""], ["H", "", "", "", "", "", "", "Test", "", "", "", "", ""], ], dtype="U40", ), ) def test_set0(self): V = {"A1": "Test", "B3": "Test"} np.testing.assert_array_equal(self.plt.set(V), self.plt) V2 = [("A3", "Bob"), ("A3" ,"_thefirst")] self.plt1.set(V2, merge=True) self.assertEqual(self.plt1["A3"], "Bob_thefirst") def test_set_again(self): with self.assertRaises(ValueError): self.plt.set("A-C[1-5]", ["Test1", "Test2"]) self.plt.set("A2", ["tezt1", "test2"]) np.testing.assert_array_equal( self.plt.set("A-C[1-5]", ["Test1", "Test2", "Test3"]), self.plt ) np.testing.assert_array_equal( self.plt.set("F-H[1-3]", ["Test1", "Test2", "Test3"]), np.array( [ [ " ", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", ], [ "A", "Test1", "Test1", "Test1", "Test1", "Test1", "", "", "", "", "", "", "", ], [ "B", "Test2", "Test2", "Test2", "Test2", "Test2", "", "", "", "", "", "", "", ], [ "C", "Test3", "Test3", "Test3", "Test3", "Test3", "", "", "", "", "", "", "", ], ["D", "", "", "", "", "", "", "", "", "", "", "", ""], ["E", "", "", "", "", "", "", "", "", "", "", "", ""], [ "F", "Test1", "Test1", "Test1", "", "", "", "", "", "", "", "", "", ], [ "G", "Test2", "Test2", "Test2", "", "", "", "", "", "", "", "", "", ], [ "H", "Test3", "Test3", "Test3", "", "", "", "", "", "", "", "", "", ], ], dtype="U40", ), ) def test_set(self): np.testing.assert_array_equal(self.plt.set("2[B,E]", "Test"), self.plt) np.testing.assert_array_equal(self.plt.set("A[1,5]", "Test"), self.plt) np.testing.assert_array_equal(self.plt.set("1C", "Test"), self.plt) np.testing.assert_array_equal( self.plt.set("1-3[A,C]", ["Test1", "Test2", "Test3"]), self.plt ) np.testing.assert_array_equal( self.plt.set("F-H[1,3]", ["Test1", "Test2", "Test3"]), self.plt ) np.testing.assert_array_equal(self.plt.set("A-D[1,3]", "Test4"), self.plt) def test_all_in_one(self): v = { "A[2,8]": "VC", "H[2,8]": "MS", "1-4[B,G]": ["MLR", "NT", "1.1", "1.2"], "E-G[8,10]": ["Val1", "Val2", "Val3"], } np.testing.assert_array_equal(self.plt.set(v), self.plt) self.assertEqual(self.plt.table(), tabulate(self.plt, headers="firstrow")) def test_save(self): self.plt.set("H4", "Test") self.assertEqual( self.plt.save("test save", db_hist_name="test_plate_historic.db"), "Plate test save with 96 wells was successfully added to database test_plate_historic.db", ) self.plt.set("H5", "lol") self.assertEqual( self.plt.save("test save", db_hist_name="test_plate_historic.db"), "plate with 1 id updated", ) phi = PlateHist(db_name="test_plate_historic.db") self.assertEqual( str(phi.get_one_hplate(1, key="id")), f"<plate N°1: test save, 96 wells, {phi.date_now}>", ) np.testing.assert_array_equal(phi.get_one_hplate(1, key="id").plate, self.plt) def test_iteration(self): ValIn = {"A1": "Control", "C[2,4]": "Test1"} self.plt.set(self.Value) self.assertEqual( list(self.plt.iterate()), [ ("A1", "Control"), ("B1", ""), ("C1", ""), ("D1", ""), ("E1", ""), ("F1", ""), ("G1", ""), ("H1", ""), ("A2", ""), ("B2", ""), ("C2", "Test1"), ("D2", ""), ("E2", ""), ("F2", ""), ("G2", ""), ("H2", ""), ("A3", ""), ("B3", ""), ("C3", "Test1"), ("D3", ""), ("E3", ""), ("F3", ""), ("G3", ""), ("H3", ""), ("A4", ""), ("B4", ""), ("C4", "Test1"), ("D4", ""), ("E4", ""), ("F4", ""), ("G4", ""), ("H4", ""), ("A5", ""), ("B5", ""), ("C5", "Test1"), ("D5", ""), ("E5", ""), ("F5", ""), ("G5", ""), ("H5", ""), ("A6", ""), ("B6", ""), ("C6", "Test1"), ("D6", ""), ("E6", ""), ("F6", ""), ("G6", ""), ("H6", ""), ("A7", ""), ("B7", ""), ("C7", "Test1"), ("D7", ""), ("E7", ""), ("F7", ""), ("G7", ""), ("H7", ""), ("A8", ""), ("B8", ""), ("C8", "Test1"), ("D8", ""), ("E8", ""), ("F8", ""), ("G8", ""), ("H8", ""), ("A9", ""), ("B9", ""), ("C9", "Test1"), ("D9", ""), ("E9", ""), ("F9", ""), ("G9", ""), ("H9", ""), ("A10", ""), ("B10", ""), ("C10", "Test1"), ("D10", ""), ("E10", ""), ("F10", ""), ("G10", ""), ("H10", ""), ("A11", ""), ("B11", "Test2"), ("C11", "Test2"), ("D11", "Test2"), ("E11", "Test2"), ("F11", "Test2"), ("G11", "Test2"), ("H11", ""), ("A12", ""), ("B12", ""), ("C12", ""), ("D12", ""), ("E12", ""), ("F12", ""), ("G12", ""), ("H12", ""), ], ) def test_count(self): ValIn = {"A1": "Control", "C[2,4]": "Test1"} self.plt.set(self.Value) self.assertEqual( self.plt.count(), {"": 80, "Control": 1, "Test1": 9, "Test2": 6} ) def test_get_value(self): self.plt.set(self.Value) np.testing.assert_array_equal(self.plt.get("C2"), "Test1") def test_get_value_row(self): self.plt.set(self.Value) np.testing.assert_array_equal( self.plt.get("C[1,6]"), ["", "Test1", "Test1", "Test1", "Test1", "Test1"] ) def test_get_values(self): self.plt.set(self.Value) self.assertEqual( self.plt.get("A1", "B[1-6]"), ["Control", ["", "", "", "", "", ""]] ) self.assertEqual(self.plt.get("A1"), "Control") np.testing.assert_array_equal( self.plt.get(1), ["Control", "", "", "", "", "", "", ""] ) np.testing.assert_array_equal( self.plt.get("C"), [ "", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test1", "Test2", "", ], ) def test_name(self): self.assertEqual(self.plt.name, "Plate") def test_to_excel(self): self.plt.to_excel("test_plate_to_excel.xlsx") exist_plate = Path("test_plate_to_excel.xlsx").exists() self.assertTrue(exist_plate) def test_all_C(self): pl = BioPlate(6, 4) pl.set(2, [3, 4]) np.testing.assert_array_equal(pl.get(2).tolist(), ["3", "4", "", ""]) def test_multi_get(self): self.plt.set("A[2-3]", [4, 5]) self.plt.set("4[D-F]", [6, 7, 8]) R1 = self.plt.get("A[2-3]", "4[D-F]") self.assertEqual(R1, [["4", "5"], ["6", "7", "8"]]) def test_merge(self): self.plt.set("A[2-3]", "Test") self.assertEqual(self.plt.get("A2"), "Test") self.plt.set("A[2-3]", ["_1", "_2"], merge=True) self.assertEqual(self.plt.get("A2"), "Test_1") self.assertEqual(self.plt.get("A3"), "Test_2") self.plt.set({"A2" : "_A", "A3" : "_B"}, merge=True) self.assertEqual(self.plt["A2"], "Test_1_A") self.assertEqual(self.plt["A3"], "Test_2_B") def test_set_get_item(self): p = BioPlate(12,8) p["A[4-6]"] = "bob" self.assertEqual(p["A6"], "bob") def test_partial_value(self): pl = BioPlate(12, 8) pl["A[5-9]"] = ["test", "test2", "test3"] def test_multi_value(self): pl = BioPlate(12,8) pl.set(self.multiValue) self.assertEqual(pl["A[2-8]"].tolist(), ["Bob"] * 7) pl1 = BioPlate(12,8) pl1.set(self.multiValue1, merge=True) self.assertEqual(pl1["A-D[1-5]"].tolist(), [ ["A_1"] * 5, ["B_2"] * 5, ["C_3"] *5, ["D_4"] *5 ])
def test_all_C(self): pl = BioPlate(6, 4) pl.set(2, [3, 4]) np.testing.assert_array_equal(pl.get(2).tolist(), ["3", "4", "", ""])
class TestPlate(unittest.TestCase): @classmethod def setUpClass(cls): """ This function is run one time at the beginning of tests :return: """ cls.pdb = PlateDB(db_name="test_plate.db") cls.pdb.add_plate( numWell=96, numColumns=12, numRows=8, surfWell=0.29, maxVolWell=200, workVolWell=200, refURL= "https://csmedia2.corning.com/LifeSciences/Media/pdf/cc_surface_areas.pdf", ) @classmethod def tearDownClass(cls): """ This function is run one time at the end of tests :return: """ with contextlib.suppress(FileNotFoundError): Path( PurePath( Path(__file__).parent.parent, "BioPlate/database/DBFiles", "test_plate.db", )).unlink() Path( PurePath( Path(__file__).parent.parent, "BioPlate/database/DBFiles", "test_plate_historic.db", )).unlink() Path( PurePath( Path(__file__).parent.parent, "BioPlate/database/DBFiles", "plate_historic.db", )).unlink() def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.Ins = BioPlate({"id": 1}, db_name="test_plate.db", inserts=True) self.Inserts = BioPlate(4, 3, inserts=True) self.Value = {"A1": "Control", "C[2,10]": "Test1", "11[B,G]": "Test2"} def tearDown(self): """ This function is run every time at the end of each test :return: """ try: Path(PurePath("test_ins_to_excel.xlsx")).unlink() except FileNotFoundError: pass def test_Plate_init(self): np.testing.assert_array_equal( self.Inserts, np.array( [ [ [" ", "1", "2", "3", "4"], ["A", "", "", "", ""], ["B", "", "", "", ""], ["C", "", "", "", ""], ], [ [" ", "1", "2", "3", "4"], ["A", "", "", "", ""], ["B", "", "", "", ""], ["C", "", "", "", ""], ], ], dtype="U40", ), ) def test_add_values(self): np.testing.assert_array_equal(self.Inserts.top.set("B3", "inserts"), self.Inserts.top) np.testing.assert_array_equal( self.Inserts.bot.set("B3", "inserts_bot"), self.Inserts.bot) self.Inserts["top", "A2"] = "Bob" self.assertEqual(self.Inserts[0, "A2"], "Bob") self.Inserts["bot", "A2"] = "Bibi" self.assertEqual(self.Inserts[1, "A2"], "Bibi") def test_add_value_row(self): np.testing.assert_array_equal( self.Inserts.top.set("B[1-3]", "inserts"), self.Inserts.top) np.testing.assert_array_equal(self.Inserts.bot.set("A", "inserts"), self.Inserts.bot) np.testing.assert_array_equal(self.Inserts.bot.set("B", "inserts2"), self.Inserts.bot) np.testing.assert_array_equal(self.Inserts.bot.set("B[1,6]", 18), self.Inserts.bot) def test_add_value_column(self): np.testing.assert_array_equal( self.Inserts.top.set("2[A,C]", "inserts"), self.Inserts.top) np.testing.assert_array_equal(self.Inserts.top.set("B", "inserts2"), self.Inserts.top) def test_set(self): with self.assertRaises(IndexError): self.Inserts.top.set(self.Value) with self.assertRaises(ValueError): self.Inserts.bot.set("A[2-4]", ["test1", "test2", "test3", "test4"]) np.testing.assert_array_equal( self.Inserts.top.set("A-C[1-3]", ["Test1", "Test2", "Test3"]), self.Inserts.top, ) Ns = BioPlate(12, 8, inserts=True) Ns["bot", "4-7[A-D]"] = ["boom1", "boom2", "boom3", "boom4"] np.testing.assert_array_equal( Ns["bot", "4-7[A-D]"], np.array([["boom1", "boom2", "boom3", "boom4"], ["boom1", "boom2", "boom3", "boom4"], ["boom1", "boom2", "boom3", "boom4"], ["boom1", "boom2", "boom3", "boom4"]])) def test_table(self): v = { "A[2,8]": "VC", "H[2,8]": "MS", "1-4[B,G]": ["MLR", "NT", "1.1", "1.2"], "E-G[8,10]": ["Val1", "Val2", "Val3"], } np.testing.assert_array_equal(self.Ins.top.set(v), self.Ins.top) self.assertEqual(self.Ins.top.table(), tabulate(self.Ins.top, headers="firstrow")) def test_save(self): self.assertEqual( self.Inserts.save("test save3", db_hist_name="test_plate_historic.db"), "Inserts test save3 with 12 wells was successfully added to database test_plate_historic.db", ) phi = PlateHist(db_name="test_plate_historic.db") np.testing.assert_array_equal( phi.get_one_hplate(1, key="id").plate, self.Inserts) def test_iteration(self): ValIn = {"A1": "Control", "C[2,4]": "Test1"} self.Inserts.top.set(ValIn) self.assertEqual( list(self.Inserts.iterate()), [ ("A1", "Control", ""), ("B1", "", ""), ("C1", "", ""), ("A2", "", ""), ("B2", "", ""), ("C2", "Test1", ""), ("A3", "", ""), ("B3", "", ""), ("C3", "Test1", ""), ("A4", "", ""), ("B4", "", ""), ("C4", "Test1", ""), ], ) def test_count(self): ValIn = {"A1": "Control", "C[2,4]": "Test1"} self.Inserts.top.set(ValIn) self.assertEqual( self.Inserts.count(), { "top": { "Control": 1, "Test1": 3, "": 8 }, "bot": { "": 12 } }, ) def test_get_value(self): self.Inserts.top.set("C2", "Test1") np.testing.assert_array_equal(self.Inserts.top.get("C2"), "Test1") def test_get_values(self): self.Inserts.bot.set("A[1-3]", ["bob1", "bob2", "bob3"]) self.Inserts.bot["B[1-3]"] = ["bibi1", "bibi2", "bibi3"] self.assertEqual(self.Inserts.bot.get("A1", "2[A-B]"), ["bob1", ["bob2", "bibi2"]]) def test_name(self): self.assertEqual(self.Inserts.name, "Inserts") self.assertEqual(self.Ins.name, "Inserts") def test_to_excel(self): self.Inserts.to_excel("test_ins_to_excel.xlsx") exist_ins = Path("test_ins_to_excel.xlsx").exists() self.assertTrue(exist_ins) def test_merge(self): ins = BioPlate(12, 8, inserts=True) ins.top.set("2-5[A-C]", ["test", "tes", "te", "t"]) self.assertEqual(ins.top.get("A2"), "test") ins.top.set("2-3[A-C]", ["_1", "_2"], merge=True) ins.top.set("A-C[4-5]", ["_3", "_4", "_5"], merge=True) self.assertEqual(ins.top.get("A2"), "test_1") self.assertEqual(ins.top.get("B3"), "tes_2") self.assertEqual(ins.top.get("A4"), "te_3") self.assertEqual(ins.top.get("B5"), "t_4") self.assertEqual(ins.top.get("C5"), "t_5") def test_raise_inserts(self): with self.assertRaises(ValueError): self.Inserts.set("A5", "martin") def test_insert_set_get(self): ii = BioPlate(12, 8, inserts=True) ii["top", "A[3-7]"] = "Bob" ii["bot", "B-D[6-9]"] = ["t1", "t2", "t3"] ii[0, "7-10[F-H]"] = ["t4", "t5", "t6", "t7"] self.assertEqual(ii.top.get("A4"), "Bob") self.assertEqual(ii.bot.get("C7"), "t2") self.assertEqual(ii.top.get("G8"), "t5") self.assertEqual(ii["top", "A5"], "Bob") self.assertEqual(ii["bot", "B6"], "t1") self.assertEqual(ii[0, "H10"], "t7") self.assertEqual(ii[1, 3, 8], "t2")
def test_partial_value(self): pl = BioPlate(12, 8) pl["A[5-9]"] = ["test", "test2", "test3"]
class TestPlateToExcel(unittest.TestCase): @classmethod def setUpClass(cls): """ This function is run one time at the beginning of tests :return: """ cls.pdb = PlateDB(db_name="test_plate.db") cls.pdb.add_plate( numWell=96, numColumns=12, numRows=8, surfWell=0.29, maxVolWell=200, workVolWell=200, refURL= "https://csmedia2.corning.com/LifeSciences/Media/pdf/cc_surface_areas.pdf", ) @classmethod def tearDownClass(cls): """ This function is run one time at the end of tests :return: """ with contextlib.suppress(FileNotFoundError): Path( PurePath( Path(__file__).parent.parent / "BioPlate/database/DBFiles" / "test_plate.db")).unlink() Path( PurePath( Path(__file__).parent.parent / "BioPlate/database/DBFiles" / "test_plate_historic.db")).unlink() Path( PurePath( Path(__file__).parent.parent / "BioPlate/database/DBFiles" / "test_plate_to_excel.xlsx")).unlink() def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.PTE = BioPlateToExcel("test.xlsx") v = { "A[2,8]": "VC", "H[2,8]": "MS", "1-4[B,G]": ["MLR", "NT", "1.1", "1.2"], "E-G[8,10]": ["Val1", "Val2", "Val3"], } v1 = { "A[2,8]": "VC1", "H[2,8]": "MS1", "1-4[B,G]": ["MLR1", "NT1", "1.3", "1.4"], "E-G[8,10]": ["Val4", "Val5", "Val6"], } v2 = { "A[2,8]": "Top", "H[2,8]": "MS", "1-4[B,G]": ["MLR", "NT", "1.1", "1.2"], "E-G[8,10]": ["Val1", "Val2", "Val3"], } v3 = { "A[2,8]": "Bot", "H[2,8]": "MS1", "1-4[B,G]": ["MLR1", "NT1", "1.3", "1.4"], "E-G[8,10]": ["Val4", "Val5", "Val6"], } self.plt = BioPlate({"id": 1}, db_name="test_plate.db") self.plt.set(v) self.plt1 = BioPlate(12, 8) self.plt1.set(v1) self.stack = self.plt + self.plt1 self.Inserts = BioPlate(12, 8, inserts=True) self.Inserts.top.set(v) self.Inserts.bot.set(v3) self.Inserts1 = BioPlate(12, 8, inserts=True) self.Inserts1.bot.set(v1) self.Inserts1.top.set(v2) self.stacki = self.Inserts + self.Inserts1 def tearDown(self): """ This function is run every time at the end of each test :return: """ with contextlib.suppress(FileNotFoundError): Path(PurePath("test.xlsx")).unlink() ###TEST DATA SHEET def test_representation_BioPlate(self): read_excel = as_read_excel(self.PTE, "representation", self.plt, "test.xlsx", "plate_representation") rm_empty = like_read_excel(self.plt) self.assertEqual(read_excel, rm_empty) def test_representation_BioPlate_hd(self): c = {"header": False} read_excel = as_read_excel( self.PTE, "representation", self.plt, "test.xlsx", "plate_representation", conditions=c, ) rm_empty = like_read_excel(self.plt, header=False) self.assertEqual(read_excel, rm_empty) def test_representation_BioPlateInserts(self): read_excel = as_read_excel( self.PTE, "representation", self.Inserts, "test.xlsx", "plate_representation", ) rm_empty = like_read_excel(self.Inserts) self.assertEqual(read_excel, rm_empty) def test_representation_BioPlateInserts_hd(self): c = {"header": False} read_excel = as_read_excel( self.PTE, "representation", self.Inserts, "test.xlsx", "plate_representation", conditions=c, ) rm_empty = like_read_excel(self.Inserts, header=False) self.assertEqual(read_excel, rm_empty) def test_representation_BioPlateStack_bp(self): read_excel = as_read_excel(self.PTE, "representation", self.stack, "test.xlsx", "plate_representation") rm_empty = like_read_excel_stack(self.stack) self.assertEqual(read_excel, rm_empty) def test_representation_BioPlateStack_bp_hd(self): c = {"header": False} read_excel = as_read_excel( self.PTE, "representation", self.stack, "test.xlsx", "plate_representation", conditions=c, ) rm_empty = like_read_excel_stack(self.stack, header=False) self.assertEqual(read_excel, rm_empty) def test_representation_BioPlateStack_bpi(self): read_excel = as_read_excel(self.PTE, "representation", self.stacki, "test.xlsx", "plate_representation") rm_empty = like_read_excel_stack(self.stacki) self.assertEqual(read_excel, rm_empty) def test_representation_BioPlateStack_bpi_hd(self): c = {"header": False} read_excel = as_read_excel( self.PTE, "representation", self.stacki, "test.xlsx", "plate_representation", conditions=c, ) rm_empty = like_read_excel_stack(self.stacki, header=False) self.assertEqual(read_excel, rm_empty) ###TEST DATA SHEET def test_data_BioPlate(self): c = None read_excel = as_read_excel(self.PTE, "data", self.plt, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data(self.plt) self.assertEqual(read_excel, rm_empty) def test_data_BioPlate_row(self): c = {"order": "R"} read_excel = as_read_excel(self.PTE, "data", self.plt, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data(self.plt, order="R") self.assertEqual(read_excel, rm_empty) def test_data_BioPlateInserts(self): c = None read_excel = as_read_excel(self.PTE, "data", self.Inserts, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data(self.Inserts) self.assertEqual(read_excel, rm_empty) def test_data_BioPlateInserts_row(self): c = {"order": "R"} read_excel = as_read_excel(self.PTE, "data", self.Inserts, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data(self.Inserts, order="R") self.assertEqual(read_excel, rm_empty) def test_data_BioPlateInserts_row_acc(self): c = {"order": "R", "accumulate": False} read_excel = as_read_excel(self.PTE, "data", self.Inserts, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data(self.Inserts, order="R", accumulate=False) self.assertEqual(read_excel, rm_empty) def test_data_BioPlateStack_bp(self): c = None read_excel = as_read_excel(self.PTE, "data", self.stack, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data_stack(self.stack) self.assertEqual(read_excel, rm_empty) def test_data_BioPlateStack_bp_row(self): c = {"order": "R"} read_excel = as_read_excel(self.PTE, "data", self.stack, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data_stack(self.stack, order="R") self.assertEqual(read_excel, rm_empty) def test_data_BioPlateStack_bp_row_acc(self): c = {"order": "R", "accumulate": False} read_excel = as_read_excel(self.PTE, "data", self.stack, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data_stack(self.stack, order="R", accumulate=False) self.assertEqual(read_excel, rm_empty) def test_data_BioPlateStack_bpi(self): c = None read_excel = as_read_excel(self.PTE, "data", self.stacki, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data_stack(self.stacki) self.assertEqual(read_excel, rm_empty) def test_data_BioPlateStack_bpi_row(self): c = {"order": "R"} read_excel = as_read_excel(self.PTE, "data", self.stacki, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data_stack(self.stacki, order="R") self.assertEqual(read_excel, rm_empty) def test_data_BioPlateStack_bpi_row_acc(self): c = {"order": "R", "accumulate": False} read_excel = as_read_excel(self.PTE, "data", self.stacki, "test.xlsx", "plate_data", conditions=c) rm_empty = like_read_data_stack(self.stacki, order="R", accumulate=False) self.assertEqual(read_excel, rm_empty) ###TEST COUNT SHEET def test_count_BioPlate(self): c = None read_excel = as_read_excel(self.PTE, "count", self.plt, "test.xlsx", "plate_count", conditions=c) rm_empty = like_read_count(self.plt) self.assertEqual(read_excel, rm_empty) def test_count_BioPlate_emp(self): c = {"empty": "vide"} read_excel = as_read_excel(self.PTE, "count", self.plt, "test.xlsx", "plate_count", conditions=c) rm_empty = like_read_count(self.plt, empty="vide") self.assertEqual(read_excel, rm_empty) def test_count_BioPlateInserts(self): c = None read_excel = as_read_excel(self.PTE, "count", self.Inserts, "test.xlsx", "plate_count", conditions=c) rm_empty = like_read_count(self.Inserts, Inserts=True) self.assertEqual(read_excel, rm_empty) def test_count_BioPlateInserts(self): c = {"empty": "vide"} read_excel = as_read_excel(self.PTE, "count", self.Inserts, "test.xlsx", "plate_count", conditions=c) rm_empty = like_read_count(self.Inserts, empty="vide", Inserts=True) self.assertEqual(read_excel, rm_empty) def test_count_BioPlateStack_bp(self): c = None read_excel = as_read_excel(self.PTE, "count", self.stack, "test.xlsx", "plate_count", conditions=c) rm_empty = like_read_count(self.stack) self.assertEqual(read_excel, rm_empty) def test_count_BioPlateStack_bp_em(self): c = {"empty": "vide"} read_excel = as_read_excel(self.PTE, "count", self.stack, "test.xlsx", "plate_count", conditions=c) rm_empty = like_read_count(self.stack, empty="vide") self.assertEqual(read_excel, rm_empty) def test_count_BioPlateStack_bpi(self): c = None read_excel = as_read_excel(self.PTE, "count", self.stacki, "test.xlsx", "plate_count", conditions=c) rm_empty = like_read_count(self.stacki, Inserts=True) self.assertEqual(read_excel, rm_empty) def test_count_BioPlateStack_bpi_em(self): c = {"empty": "vide"} read_excel = as_read_excel(self.PTE, "count", self.stacki, "test.xlsx", "plate_count", conditions=c) rm_empty = like_read_count(self.stacki, empty="vide", Inserts=True) self.assertEqual(read_excel, rm_empty) def test_error_init(self): with self.assertRaises(ValueError): BioPlateToExcel("test.xlsx", sheets=[ "bob", ], test=True) with self.assertRaises(Exception): BioPlateToExcel("test.xlsx", sheets="bob") def test_in_memory(self): t = BioPlateToExcel("test.xlsx", test=True) self.assertEqual(t.get_test(), b'') x = BioPlateToExcel("test.xlsx") self.assertEqual(x.get_test(), None)
def setUpClass(cls): """ This function is run one time at the beginning of tests :return: """ cls.plt = BioPlate(12, 8) cls.plt1 = BioPlate(12, 8) cls.stack = cls.plt + cls.plt1 cls.inserts = BioPlate(12, 8, inserts=True) cls.inserts1 = BioPlate(12, 8, inserts=True) Value = { "A1": "A1", "A2": "A2", "A3": "A3", "A4": "A4", "A5": "A5", "A6": "A6", "A7": "A7", "A8": "A8", "A9": "A9", "A10": "A10", "A11": "A11", "A12": "A12", "B1": "B1", "B2": "B2", "B3": "B3", "B4": "B4", "B5": "B5", "B6": "B6", "B7": "B7", "B8": "B8", "B9": "B9", "B10": "B10", "B11": "B11", "B12": "B12", "C1": "C1", "C2": "C2", "C3": "C3", "C4": "C4", "C5": "C5", "C6": "C6", "C7": "C7", "C8": "C8", "C9": "C9", "C10": "C10", "C11": "C11", "C12": "C12", "D1": "D1", "D2": "D2", "D3": "D3", "D4": "D4", "D5": "D5", "D6": "D6", "D7": "D7", "D8": "D8", "D9": "D9", "D10": "D10", "D11": "D11", "D12": "D12", "E1": "E1", "E2": "E2", "E3": "E3", "E4": "E4", "E5": "E5", "E6": "E6", "E7": "E7", "E8": "E8", "E9": "E9", "E10": "E10", "E11": "E11", "E12": "E12", "F1": "F1", "F2": "F2", "F3": "F3", "F4": "F4", "F5": "F5", "F6": "F6", "F7": "F7", "F8": "F8", "F9": "F9", "F10": "F10", "F11": "F11", "F12": "F12", "G1": "G1", "G2": "G2", "G3": "G3", "G4": "G4", "G5": "G5", "G6": "G6", "G7": "G7", "G8": "G8", "G9": "G9", "G10": "G10", "G11": "G11", "G12": "G12", "H1": "H1", "H2": "H2", "H3": "H3", "H4": "H4", "H5": "H5", "H6": "H6", "H7": "H7", "H8": "H8", "H9": "H9", "H10": "H10", "H11": "H11", "H12": "H12", } Value2 = {key: key + "plt1" for key in Value.keys()} Value3 = {"A1": "Control", "C[2,10]": "Test1", "11[B,G]": "Test2"} Value4 = {"A1": "Control1", "D[2,9]": "Test3", "12[B,H]": "Test4"} cls.plt.set(Value) cls.plt1.set(Value2) cls.inserts.top.set(Value) cls.inserts1.top.set(Value3) cls.inserts1.bot.set(Value4) cls.stacki = cls.inserts + cls.inserts1
def test_iteration(self): pltx = BioPlate(12, 8) plti = BioPlate(12, 8) plti.set(self.Value) multi = plti + pltx.set(self.Value) self.assertEqual( list(multi.iterate(accumulate=True)), [ ("A1", "Control", "Control"), ("B1", "", ""), ("C1", "", ""), ("D1", "", ""), ("E1", "", ""), ("F1", "", ""), ("G1", "", ""), ("H1", "", ""), ("A2", "", ""), ("B2", "", ""), ("C2", "Test1", "Test1"), ("D2", "", ""), ("E2", "", ""), ("F2", "", ""), ("G2", "", ""), ("H2", "", ""), ("A3", "", ""), ("B3", "", ""), ("C3", "Test1", "Test1"), ("D3", "", ""), ("E3", "", ""), ("F3", "", ""), ("G3", "", ""), ("H3", "", ""), ("A4", "", ""), ("B4", "", ""), ("C4", "Test1", "Test1"), ("D4", "", ""), ("E4", "", ""), ("F4", "", ""), ("G4", "", ""), ("H4", "", ""), ("A5", "", ""), ("B5", "", ""), ("C5", "Test1", "Test1"), ("D5", "", ""), ("E5", "", ""), ("F5", "", ""), ("G5", "", ""), ("H5", "", ""), ("A6", "", ""), ("B6", "", ""), ("C6", "Test1", "Test1"), ("D6", "", ""), ("E6", "", ""), ("F6", "", ""), ("G6", "", ""), ("H6", "", ""), ("A7", "", ""), ("B7", "", ""), ("C7", "Test1", "Test1"), ("D7", "", ""), ("E7", "", ""), ("F7", "", ""), ("G7", "", ""), ("H7", "", ""), ("A8", "", ""), ("B8", "", ""), ("C8", "Test1", "Test1"), ("D8", "", ""), ("E8", "", ""), ("F8", "", ""), ("G8", "", ""), ("H8", "", ""), ("A9", "", ""), ("B9", "", ""), ("C9", "Test1", "Test1"), ("D9", "", ""), ("E9", "", ""), ("F9", "", ""), ("G9", "", ""), ("H9", "", ""), ("A10", "", ""), ("B10", "", ""), ("C10", "Test1", "Test1"), ("D10", "", ""), ("E10", "", ""), ("F10", "", ""), ("G10", "", ""), ("H10", "", ""), ("A11", "", ""), ("B11", "Test2", "Test2"), ("C11", "Test2", "Test2"), ("D11", "Test2", "Test2"), ("E11", "Test2", "Test2"), ("F11", "Test2", "Test2"), ("G11", "Test2", "Test2"), ("H11", "", ""), ("A12", "", ""), ("B12", "", ""), ("C12", "", ""), ("D12", "", ""), ("E12", "", ""), ("F12", "", ""), ("G12", "", ""), ("H12", "", ""), ], ) self.assertEqual( list(multi.iterate(accumulate=False)), [ ("A1", "Control"), ("B1", ""), ("C1", ""), ("D1", ""), ("E1", ""), ("F1", ""), ("G1", ""), ("H1", ""), ("A2", ""), ("B2", ""), ("C2", "Test1"), ("D2", ""), ("E2", ""), ("F2", ""), ("G2", ""), ("H2", ""), ("A3", ""), ("B3", ""), ("C3", "Test1"), ("D3", ""), ("E3", ""), ("F3", ""), ("G3", ""), ("H3", ""), ("A4", ""), ("B4", ""), ("C4", "Test1"), ("D4", ""), ("E4", ""), ("F4", ""), ("G4", ""), ("H4", ""), ("A5", ""), ("B5", ""), ("C5", "Test1"), ("D5", ""), ("E5", ""), ("F5", ""), ("G5", ""), ("H5", ""), ("A6", ""), ("B6", ""), ("C6", "Test1"), ("D6", ""), ("E6", ""), ("F6", ""), ("G6", ""), ("H6", ""), ("A7", ""), ("B7", ""), ("C7", "Test1"), ("D7", ""), ("E7", ""), ("F7", ""), ("G7", ""), ("H7", ""), ("A8", ""), ("B8", ""), ("C8", "Test1"), ("D8", ""), ("E8", ""), ("F8", ""), ("G8", ""), ("H8", ""), ("A9", ""), ("B9", ""), ("C9", "Test1"), ("D9", ""), ("E9", ""), ("F9", ""), ("G9", ""), ("H9", ""), ("A10", ""), ("B10", ""), ("C10", "Test1"), ("D10", ""), ("E10", ""), ("F10", ""), ("G10", ""), ("H10", ""), ("A11", ""), ("B11", "Test2"), ("C11", "Test2"), ("D11", "Test2"), ("E11", "Test2"), ("F11", "Test2"), ("G11", "Test2"), ("H11", ""), ("A12", ""), ("B12", ""), ("C12", ""), ("D12", ""), ("E12", ""), ("F12", ""), ("G12", ""), ("H12", ""), ("A1", "Control"), ("B1", ""), ("C1", ""), ("D1", ""), ("E1", ""), ("F1", ""), ("G1", ""), ("H1", ""), ("A2", ""), ("B2", ""), ("C2", "Test1"), ("D2", ""), ("E2", ""), ("F2", ""), ("G2", ""), ("H2", ""), ("A3", ""), ("B3", ""), ("C3", "Test1"), ("D3", ""), ("E3", ""), ("F3", ""), ("G3", ""), ("H3", ""), ("A4", ""), ("B4", ""), ("C4", "Test1"), ("D4", ""), ("E4", ""), ("F4", ""), ("G4", ""), ("H4", ""), ("A5", ""), ("B5", ""), ("C5", "Test1"), ("D5", ""), ("E5", ""), ("F5", ""), ("G5", ""), ("H5", ""), ("A6", ""), ("B6", ""), ("C6", "Test1"), ("D6", ""), ("E6", ""), ("F6", ""), ("G6", ""), ("H6", ""), ("A7", ""), ("B7", ""), ("C7", "Test1"), ("D7", ""), ("E7", ""), ("F7", ""), ("G7", ""), ("H7", ""), ("A8", ""), ("B8", ""), ("C8", "Test1"), ("D8", ""), ("E8", ""), ("F8", ""), ("G8", ""), ("H8", ""), ("A9", ""), ("B9", ""), ("C9", "Test1"), ("D9", ""), ("E9", ""), ("F9", ""), ("G9", ""), ("H9", ""), ("A10", ""), ("B10", ""), ("C10", "Test1"), ("D10", ""), ("E10", ""), ("F10", ""), ("G10", ""), ("H10", ""), ("A11", ""), ("B11", "Test2"), ("C11", "Test2"), ("D11", "Test2"), ("E11", "Test2"), ("F11", "Test2"), ("G11", "Test2"), ("H11", ""), ("A12", ""), ("B12", ""), ("C12", ""), ("D12", ""), ("E12", ""), ("F12", ""), ("G12", ""), ("H12", ""), ], )
class TestPlate(unittest.TestCase): @classmethod def setUpClass(cls): """ This function is run one time at the beginning of tests :return: """ pass @classmethod def tearDownClass(cls): """ This function is run one time at the end of tests :return: """ pass def setUp(self): """ This function is run every time at the beginning of each test :return: """ self.plt = BioPlate(12, 8) self.plt1 = BioPlate(12, 8) self.stack = self.plt + self.plt1 self.Inserts = BioPlate(12, 8, inserts=True) self.Inserts1 = BioPlate(12, 8, inserts=True) self.stacki = self.Inserts + self.Inserts1 self.Value = {"A1": "Control", "C[2,10]": "Test1", "11[B,G]": "Test2"} self.Value2 = {"A1": "Control1", "D[2,9]": "Test3", "12[B,H]": "Test4"} def test_reverse(self): pass def tearDown(self): """ This function is run every time at the end of each test :return: """ pass def test_count_BioPlate(self): self.assertDictEqual( BioPlateCount(self.plt.set(self.Value)), { "": 80, "Control": 1, "Test1": 9, "Test2": 6 }, ) self.assertDictEqual( BioPlateCount(self.plt.set(self.Value), reverse=True), { "": 80, "Control": 1, "Test2": 6, "Test1": 9 }, ) def test_count_BioPlateInserts(self): self.Inserts.top.set(self.Value) self.Inserts.bot.set(self.Value2) self.assertDictEqual( BioPlateCount(self.Inserts), { "top": { "Control": 1, "Test1": 9, "Test2": 6, "": 80 }, "bot": { "Control1": 1, "Test3": 8, "Test4": 7, "": 80 }, }, ) def test_count_BioPlateStack_BioPlate(self): self.plt.set(self.Value) self.plt1.set(self.Value2) self.assertDictEqual( BioPlateCount(self.stack), { 0: { "Control": 1, "Test1": 9, "Test2": 6, "": 80 }, 1: { "Control1": 1, "Test3": 8, "Test4": 7, "": 80 }, }, ) def test_count_BioPlateStack_BioPlateInserts(self): self.Inserts.top.set(self.Value) self.Inserts.bot.set(self.Value2) self.Inserts1.top.set(self.Value) self.Inserts1.bot.set(self.Value2) self.assertEqual( BioPlateCount(self.stacki), { 0: { "top": { "Control": 1, "Test2": 6, "Test1": 9, "": 80 }, "bot": { "Control1": 1, "Test3": 8, "Test4": 7, "": 80 }, }, 1: { "top": { "Control": 1, "Test1": 9, "Test2": 6, "": 80 }, "bot": { "Control1": 1, "Test3": 8, "Test4": 7, "": 80 }, }, }, )