def setUp(self): self.testInfo1 = personalInfo("test1", "0101111111", "aaaa") self.testInfo2 = personalInfo("test2", "0102222222", "bbbb") self.testInfo3 = personalInfo("test3", "0103333333", "cccc") self.list = linkedlist() self.list.append(self.testInfo1) self.list.append(self.testInfo2) self.list.append(self.testInfo3)
def setUp(self): self.testInfo1 = personalInfo("test1", "0101111111", "aaaa") self.testInfo2 = personalInfo("test2", "0102222222", "bbbb") self.testInfo3 = personalInfo("test3", "0103333333", "cccc") self.list = linkedlist() self.list.append(self.testInfo1) self.list.append(self.testInfo2) self.list.append(self.testInfo3)
def setUp(self): self.book = addressBookCtrl.addressbook() self.testInfo1 = personInfo.personalInfo("test1", "0001111111", "aaa") self.testInfo2 = personInfo.personalInfo("test2", "0002222222", "bbb") self.testInfo3 = personInfo.personalInfo("test3", "0003333333", "ccc") self.book.input(self.testInfo1) self.book.input(self.testInfo2) self.book.input(self.testInfo3)
def modify(self): if (self.isEmpty() == True): self.print_error(self.ERROR_EMPTY) return None name = raw_input("수정할 이름: ") modifyIndex = self.list.find(name) if (modifyIndex == -1): self.print_error(self.ERROR_NOT_SEARCH) return None self.printHeader(-1) self.printPersonInfo(self.list.viewAt(modifyIndex), -1) yesno = raw_input("수정하시겠습니까? (y/n) : ") info = personInfo.personalInfo() if (yesno == 'y' or 'Y'): info.name = raw_input("이름 : ") info.phone = raw_input("전화번호 : ") info.address = raw_input("주소 : ") print "수정된 정보" target = self.list.getNode(modifyIndex) target.data = info self.printHeader(-1) self.printPersonInfo(target.data, -1) print "수정되었습니다."
def modify(self): if (self.isEmpty() == True): self.print_error(self.ERROR_EMPTY) return None name = raw_input("수정할 이름: ") modifyIndex = self.list.find(name) if (modifyIndex == -1): self.print_error(self.ERROR_NOT_SEARCH) return None self.printHeader(-1) self.printPersonInfo(self.list.viewAt(modifyIndex), -1) yesno = raw_input("수정하시겠습니까? (y/n) : ") info = personInfo.personalInfo() if (yesno == 'y' or 'Y'): info.name = raw_input("이름 : ") info.phone = raw_input("전화번호 : ") info.address = raw_input("주소 : ") print "수정된 정보" target = self.list.getNode(modifyIndex) target.data = info self.printHeader(-1) self.printPersonInfo(target.data, -1) print "수정되었습니다."
def test_insert(self): self.testInfo4 = personalInfo("test4", "0104444444", "dddd") self.list.insert(1, self.testInfo4) self.assertEqual(self.list.getLength(), 4) self.assertEqual(self.list.viewAt(1).name, "test4") self.assertEqual(self.list.viewAt(1).phone, "0104444444") self.assertEqual(self.list.viewAt(1).address, "dddd")
def test_insert(self): self.testInfo4 = personalInfo("test4", "0104444444", "dddd") self.list.insert(1, self.testInfo4) self.assertEqual(self.list.getLength(), 4) self.assertEqual(self.list.viewAt(1).name, "test4") self.assertEqual(self.list.viewAt(1).phone, "0104444444") self.assertEqual(self.list.viewAt(1).address, "dddd")
def test_append(self): self.testInfo4 = personalInfo("test4", "0104444444", "dddd") self.list.append(self.testInfo4) self.assertEqual(self.list.getLength(), 4) #self.assertEqual(self.list.pos.data.name,"test4") #self.assertEqual(self.list.pos.data.phone, "0104444444") #self.assertEqual(self.list.pos.data.address, "dddd") self.assertEqual(self.list.viewAt(3).name, "test4") self.assertEqual(self.list.viewAt(3).phone, "0104444444") self.assertEqual(self.list.viewAt(3).address, "dddd")
def test_append(self): self.testInfo4 = personalInfo("test4", "0104444444", "dddd") self.list.append(self.testInfo4) self.assertEqual(self.list.getLength(), 4) #self.assertEqual(self.list.pos.data.name,"test4") #self.assertEqual(self.list.pos.data.phone, "0104444444") #self.assertEqual(self.list.pos.data.address, "dddd") self.assertEqual(self.list.viewAt(3).name, "test4") self.assertEqual(self.list.viewAt(3).phone, "0104444444") self.assertEqual(self.list.viewAt(3).address, "dddd")
def input(self): info = personInfo.personalInfo() info.name = raw_input("이름 : ") info.phone = raw_input("전화번호 : ") info.address = raw_input("주소 : ") print "입력된 정보" self.printHeader(-1) self.printPersonInfo(info, -1) yesno = raw_input("추가하시겠습니까? (y/n) : ") if (yesno == 'y' or 'Y'): self.list.append(info) print "추가되었습니다."
def input(self): info = personInfo.personalInfo() info.name = raw_input("이름 : ") info.phone = raw_input("전화번호 : ") info.address = raw_input("주소 : ") print "입력된 정보" self.printHeader(-1) self.printPersonInfo(info, -1) yesno = raw_input("추가하시겠습니까? (y/n) : ") if (yesno == 'y' or 'Y'): self.list.append(info) print "추가되었습니다."
def load(self): self.list.deleteAll() f = open('addressbook.dat', 'r') f.seek(0,2) eof = f.tell() f.seek(0) while True: info = personInfo.personalInfo() info.name = f.readline().rstrip('\n') info.phone = f.readline().rstrip('\n') info.address = f.readline().rstrip('\n') self.list.append(info) if eof == f.tell(): break print "addressbook.dat 파일을 불러왔습니다."
def load_db(self): self.list.deleteAll() con = mdb.connect('localhost', 'root', 'qwop1290', 'studydb') with con: cur = con.cursor(mdb.cursors.DictCursor) cur.execute("SELECT * FROM addressbook") rows = cur.fetchall() for row in rows: info = personInfo.personalInfo() info.name = row['name'] info.phone = row['phone'] info.address = row['address'] self.list.append(info) print "studydb database내 addressbook table을 불러왔습니다."
def testSetup(self): samples = [] info = personInfo.personalInfo() info.name = "aaa" info.phone = "0001112222" info.address = "acb" samples.append(info) info = personInfo.personalInfo() info.name = "bbb" info.phone = "000111333" info.address = "acb" samples.append(info) info = personInfo.personalInfo() info.name = "ccc" info.phone = "000111444" info.address = "acb" samples.append(info) info = personInfo.personalInfo() info.name = "ddd" info.phone = "0001115555" info.address = "acb" samples.append(info) info = personInfo.personalInfo() info.name = "eee" info.phone = "0001116666" info.address = "acb" samples.append(info) info = personInfo.personalInfo() info.name = "fff" info.phone = "0001117777" info.address = "acb" samples.append(info) info = personInfo.personalInfo() info.name = "ggg" info.phone = "0001118888" info.address = "acb" samples.append(info) info = personInfo.personalInfo() info.name = "hhh" info.phone = "0001119999" info.address = "acb" samples.append(info) info = personInfo.personalInfo() info.name = "iii" info.phone = "0002220000" info.address = "acb" samples.append(info) info = personInfo.personalInfo() info.name = "jjj" info.phone = "0002221111" info.address = "acb" samples.append(info) for index in range(10): self.list.append(samples[index])
def test_modify(self): testInfo = personInfo.personalInfo("test4", "0004444444", "ddd") self.book.modify(0, testInfo) self.assertEqual(self.book.list.getNode(0).data.name, testInfo.name) self.assertEqual(self.book.list.getNode(0).data.phone, testInfo.phone) self.assertEqual(self.book.list.getNode(0).data.address, testInfo.address)