1
2
3
4
5
6
7
8
9
10
11
12 import os, sys
13 import unittest
14 from ctypes import Structure, sizeof, string_at, cast, c_char, c_void_p
15
16 path = os.path.join(os.path.split(os.getcwd())[0], "src")
17 sys.path.insert(0, path)
18
19
20 from dlinklist import APIException, FunctionException, DLinklist, Return, \
21 SrchOrigin, SrchDir, InsertDir
22 from dlinklist.linklist import List
23
24 -class Info(Structure):
25 _fields_ = (
26 ('value', c_char * 50),
27 )
28
29
31 """
32 This class runs testunit test on all the function in my C{C} linklist
33 library.
34 """
35
37 """
38 Initializes the C{TestLibDll} class.
39
40 1. Call the constructor of the base class.
41 2. Create an aggreget of the C{DLinklist} class.
42 3. Define an object to be used for a C{ctypes} C{POINTER} object.
43
44 @param name: The name used by the C{TestCase} class.
45 @raise LibraryNotFoundException: If the C{C} library cannot be found.
46 """
47 super(TestLibDll, self).__init__(name)
48 self._dll = DLinklist(disableLogging=True)
49 self._list_p = None
50
52 """
53 Initialize the list for each unit test.
54
55 @return: C{None}
56 """
57
58 self._list_p = self._initList(sizeof(Info))
59
60
62 """
63 Destroy entire list.
64
65 @return: C{None}
66 """
67
68 self._destroyList()
69
71 """
72 Check that the C{Info} class is the correct type.
73
74 @return: C{None}
75 """
76 msg = "Invalid Info type is not a subclass of ctypes Structure."
77
78 try:
79 self._dll.checkInfoType(Info())
80 except:
81 self.fail(msg)
82
83 class BadInfo(object):
84 pass
85
86 try:
87 self._dll.checkInfoType(BadInfo())
88 self.fail(msg)
89 except APIException:
90 pass
91
93 """
94 Test that the C{Python} C{List} object is the same size as the C{C}
95 C{List} structure.
96
97 @return: C{None}
98 """
99 pSizeof = sizeof(List)
100 cSizeof = self._dll._lib._getListSize()
101 msg = "Python sizeof(List): %s, C sizeof(List): %s" % (pSizeof, cSizeof)
102 self.assertTrue(pSizeof == cSizeof, msg=msg)
103
105 """
106 Test that a string is returned.
107
108 The C{C} function doc string::
109
110 Ver: 1.3.0 Dec 24 2011
111 -------------------------------
112 Developed by: Carl J. Nobile
113 Contributions: Charlie Buckheit
114 Graham Inchley
115 Wai-Sun Chia
116 Mark M. Feenstra
117 Lianqi Qiu
118
119 @return: C{None}
120 """
121 devBy = " Developed by: Carl J. Nobile"
122 version = string_at(self._dll.version())
123
124 try:
125 self.assertIn(devBy, version)
126 except:
127 self.assertTrue(devBy in version)
128
130 """
131 Check that the list is empty.
132
133 @return: C{None}
134 """
135 self._isListEmpty(test=True)
136
138 """
139 Check that the list is not full.
140
141 @return: C{None}
142 """
143 self._isListFull(test=False)
144
157
174
186
199
217
236
256
275
296
335
368
414
436
453
455 """
456 Check that the entire list is deleted properly, the index values are
457 correct after the delete, and the correct return codes are returned.
458
459 @return: C{None}
460 """
461
462 self._deleteEntireList(result=Return.NULL_LIST)
463
464 values = []
465 values.append("ZZZZ - This is test record one.")
466 values.append("AAAA - This is test record two.")
467 values.append("NNNN - This is test record three.")
468
469 for value in values:
470 self._addRecord(Info(value))
471
472 self._getNumberOfRecords(test=3)
473 self._deleteEntireList()
474 self._isListEmpty(test=True)
475
477 """
478 Check that records are found correctly, the index values are correct
479 after each query, and the correct return codes are returned.
480
481 @return: C{None}
482 """
483
484 self._findRecord(Info(), Info(), None,
485 result=Return.NULL_FUNCTION)
486
487 self._findRecord(Info(), Info(), self._dll.compare(),
488 result=Return.NULL_LIST)
489
490 values = []
491 values.append("ZZZZ - This is test record one.")
492 values.append("AAAA - This is test record two.")
493 values.append("NNNN - This is test record three.")
494
495 for value in values:
496 self._addRecord(Info(value))
497
498 self._getNumberOfRecords(test=3)
499 record = Info()
500 self._findRecord(record, Info(values[1]), self._dll.compare())
501
502 self._findRecord(record, Info("Record not found."),
503 self._dll.compare(), result=Return.NOT_FOUND)
504
506 """
507 Check that records are found correctly based on the skip value, the
508 index values are correct after each query, and the correct return
509 codes are returned.
510
511 @return: C{None}
512 """
513
514 self._findNthRecord(Info(), 1, result=Return.NULL_LIST)
515
516
517 values = []
518 values.append("ZZZZ - This is test record one.")
519 values.append("AAAA - This is test record two.")
520 values.append("NNNN - This is test record three.")
521 values.append("YYYY - This is test record four.")
522 values.append("BBBB - This is test record five.")
523 values.append("MMMM - This is test record six.")
524
525 for value in values:
526 self._addRecord(Info(value))
527
528 self._getNumberOfRecords(test=6)
529 self._getCurrentIndex(test=6)
530 self._findNthRecord(Info(), 1, test=values[1])
531 self._getCurrentIndex(test=2)
532 self._findNthRecord(Info(), 5, test=values[5])
533 self._getCurrentIndex(test=6)
534
535 self._findNthRecord(Info(), 0, test=values[1],
536 result=Return.NOT_FOUND)
537 self._findNthRecord(Info(), 6, test=values[1],
538 result=Return.NOT_FOUND)
539
540 self._setSearchModes(SrchOrigin.TAIL, SrchDir.UP)
541 self._findNthRecord(Info(), 1, test=values[4])
542 self._getCurrentIndex(test=5)
543 self._findNthRecord(Info(), 5, test=values[0])
544 self._getCurrentIndex(test=1)
545
546 self._findNthRecord(Info(), 6, test=values[5],
547 result=Return.NOT_FOUND)
548
549 self._setSearchModes(SrchOrigin.CURRENT, SrchDir.DOWN)
550
551
552 self._incrementCurrentPointer()
553 self._incrementCurrentPointer()
554 self._findNthRecord(Info(), 1, test=values[3])
555 self._getCurrentIndex(test=4)
556
557 self._findNthRecord(Info(), 3, test=values[5],
558 result=Return.NOT_FOUND)
559 self._getCurrentIndex(test=4)
560
561 self._setSearchModes(SrchOrigin.CURRENT, SrchDir.UP)
562 self._findNthRecord(Info(), 1, test=values[2])
563 self._getCurrentIndex(test=3)
564
565 self._findNthRecord(Info(), 3, test=values[0],
566 result=Return.NOT_FOUND)
567 self._getCurrentIndex(test=3)
568
584
605
626
628 """
629 Check that the list is saved and loaded correctly, the index values are
630 correct after the loads, the sorting on load is done properly, and the
631 correct return codes are returned.
632
633 @return: C{None}
634 """
635 filePath = "/tmp/unittest.data"
636
637 self._saveList(filePath, result=Return.NULL_LIST)
638
639 values = []
640 values.append("ZZZZ - This is test record one.")
641 values.append("AAAA - This is test record two.")
642 values.append("NNNN - This is test record three.")
643 values.append("YYYY - This is test record four.")
644 values.append("BBBB - This is test record five.")
645 values.append("MMMM - This is test record six.")
646
647 for value in values:
648 self._addRecord(Info(value))
649
650 self._getNumberOfRecords(test=6)
651 self._saveList(filePath)
652
653 self._saveList(filePath, result=Return.NOT_MODIFIED)
654
655 self._loadList(filePath, self._dll.compare())
656
657
658 self._getCurrentIndex(test=3)
659 self._currentPointerToHead()
660 self._getCurrentIndex(test=1)
661
662 self._loadList("", self._dll.compare(), result=Return.OPEN_ERROR)
663 self._getCurrentIndex(test=1)
664 os.remove(filePath)
665
666
667
668
670 """
671 Prepare the link list for use and asserts that there are no
672 C{APIException} or C{FunctionException} exceptions, and the C{list_p}
673 object is valid.
674
675 @param infoSize: The size in bytes of the user defined C{Info} class.
676 @type infoSize: C{int}
677 @return: A pinter to the link list.
678 @rtype: C{ctypes POINTER}
679 """
680 try:
681 list_p = self._dll.create(infoSize)
682 except APIException, e:
683 self.fail(e)
684 except FunctionException, e:
685 self.fail(e)
686
687 msg = "DLL_CreateList failed, list_p: %s."
688 self.assertTrue(list_p not in (0, None),
689 msg=msg % hex(cast(list_p, c_void_p).value))
690 return list_p
691
693 """
694 Executes the C{destroyList} method and asserts that there are no
695 C{APIException} exceptions.
696
697 @return: C{None}
698 """
699 try:
700 self._dll.destroyList()
701 except APIException, e:
702 self.fail(e)
703
705 """
706 Executes the C{isListEmpty} method, asserts that there are no
707 C{APIException} exceptions, and asserts that the returned value is
708 correct.
709
710 @keyword test: The expected value, the default is C{True}.
711 @type test: C{bool}
712 @return: C{None}
713 """
714 try:
715 retval = self._dll.isListEmpty()
716 except APIException, e:
717 self.fail(e)
718
719 msg = "retval: %s, test: %s"
720 self.assertTrue(retval == test, msg=msg % (retval, test))
721
723 """
724 Execute the C{isListFull} method, asserts that there are no
725 C{APIException} exceptions, and asserts that the return value is
726 correct.
727
728 @keyword test: The expected value, the default is C{True}.
729 @type test: C{bool}
730 @return: C{None}
731 """
732 try:
733 retval = self._dll.isListFull()
734 except APIException, e:
735 self.fail(e)
736
737 msg = "retval: %s, test: %s"
738 self.assertTrue(retval == test, msg=msg % (retval, test))
739
741 """
742 Execute the C{getNumberOfRecords} method, asserts that there are no
743 C{APIException} exceptions, and asserts that the returned value is
744 correct.
745
746 @keyword test: The expected value, the default is C{0}.
747 @type test: C{int}
748 @return: C{None}
749 """
750 try:
751 retval = self._dll.getNumberOfRecords()
752 except APIException, e:
753 self.fail(e)
754
755 msg = "retval: %s, test: %s"
756 self.assertTrue(retval == test, msg=msg % (retval, test))
757
759 """
760 Execute the C{setSearchModes} method, asserts that there are no
761 C{APIException} or C{FunctionException} exceptions, and asserts that
762 the return code is correct.
763
764 @keyword result: The expected value, the default is C{Return.NORMAL}.
765 @type result: C{Return}
766 @return: C{None}
767 """
768 try:
769 retval = self._dll.setSearchModes(origin, dir)
770 except APIException, e:
771 self.fail(e)
772 except FunctionException, e:
773 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
774 self.assertTrue(e.getRetval() == result, msg=msg)
775
777 """
778 Execute the C{getSearchModes} method, asserts that there are no
779 C{APIException} exceptions, and asserts that the returned C{tuple} is
780 correct.
781
782 @keyword test: The expected value, the default is
783 C{(SrchOrigin.HEAD, SrchDir.DOWN)}.
784 @type test: C{tuple} of C{SrchOrigin} and C{SrchDir}
785 @return: C{None}
786 """
787 try:
788 origin, direction = self._dll.getSearchModes()
789 except APIException, e:
790 self.fail(e)
791
792
793 msg = "SrchOrigin.%s: %s" % SrchOrigin.getMessage(origin)
794 self.assertTrue(origin == test[0], msg=msg)
795 msg = "SrchDir.%s: %s" % SrchDir.getMessage(direction)
796 self.assertTrue(direction == test[1], msg=msg)
797
799 """
800 Execute the C{getCurrentIndex} method, asserts that there are no
801 C{APIException} exceptions, and asserts that the returned value is
802 correct.
803
804 @keyword test: The expected value, the default is C{0}.
805 @type test: C{int}
806 @return: C{None}
807 """
808 try:
809 retval = self._dll.getCurrentIndex()
810 except APIException, e:
811 self.fail(e)
812
813 msg = "retval: %s, test: %s"
814 self.assertTrue(retval == test, msg=msg % (retval, test))
815
817 """
818 Execute the C{currentPointerToHead} method, asserts that there are no
819 C{APIException} or C{FunctionException} exceptions, and asserts that
820 the return code is correct.
821
822 @keyword result: The expected value, the default is C{Return.NORMAL}.
823 @type result: C{Return}
824 @return: C{None}
825 """
826 try:
827 retval = self._dll.currentPointerToHead()
828 except APIException, e:
829 self.fail(e)
830 except FunctionException, e:
831 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
832 self.assertTrue(e.getRetval() == result, msg=msg)
833
835 """
836 Execute the C{currentPointerToTail} method, asserts that there are no
837 C{APIException} or C{FunctionException} exceptions, and asserts that
838 the return code is correct.
839
840 @keyword result: The expected value, the default is C{Return.NORMAL}.
841 @type result: C{Return}
842 @return: C{None}
843 """
844 try:
845 retval = self._dll.currentPointerToTail()
846 except APIException, e:
847 self.fail(e)
848 except FunctionException, e:
849 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
850 self.assertTrue(e.getRetval() == result, msg=msg)
851
853 """
854 Execute the C{incrementCurrentPointer} method, asserts that there are
855 no C{APIException} or C{FunctionException} exceptions, and asserts that
856 the return code is correct.
857
858 @keyword result: The expected value, the default is C{Return.NORMAL}.
859 @type result: C{Return}
860 @return: C{None}
861 """
862 try:
863 retval = self._dll.incrementCurrentPointer()
864 except APIException, e:
865 self.fail(e)
866 except FunctionException, e:
867 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
868 self.assertTrue(e.getRetval() == result, msg=msg)
869
871 """
872 Execute the C{decrementCurrentPointer} method, asserts that there are
873 no C{APIException} or C{FunctionException} exceptions, and asserts that
874 the return code is correct.
875
876 @keyword result: The expected value, the default is C{Return.NORMAL}.
877 @type result: C{Return}
878 @return: C{None}
879 """
880 try:
881 retval = self._dll.decrementCurrentPointer()
882 except APIException, e:
883 self.fail(e)
884 except FunctionException, e:
885 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
886 self.assertTrue(e.getRetval() == result, msg=msg)
887
889 """
890 Execute the C{storeCurrentPointer} method, asserts that there are no
891 C{APIException} or C{FunctionException} exceptions, and asserts that
892 the return code is correct.
893
894 @keyword result: The expected value, the default is C{Return.NORMAL}.
895 @type result: C{Return}
896 @return: C{None}
897 """
898 try:
899 retval = self._dll.storeCurrentPointer()
900 except APIException, e:
901 self.fail(e)
902 except FunctionException, e:
903 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
904 self.assertTrue(e.getRetval() == result, msg=msg)
905
907 """
908 Execute the C{restoreCurrentPointer} method, asserts that there are no
909 C{APIException} or C{FunctionException} exceptions, and asserts that
910 the return code is correct.
911
912 @keyword result: The expected value, the default is C{Return.NORMAL}.
913 @type result: C{Return}
914 @return: C{None}
915 """
916 try:
917 retval = self._dll.restoreCurrentPointer()
918 except APIException, e:
919 self.fail(e)
920 except FunctionException, e:
921 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
922 self.assertTrue(e.getRetval() == result, msg=msg)
923
925 """
926 Execute the C{addRecord} method, asserts that there are no
927 C{APIException} or C{FunctionException} exceptions, and asserts that
928 the return code is correct.
929
930 @param info: An instance of the C{Info} class.
931 @type info: C{Info}
932 @keyword pFun: An optional compare function, the default is C{None}.
933 @type pFun: C{ctypes CFUNCTYPE}
934 @keyword result: The expected value, the default is C{Return.NORMAL}.
935 @type result: C{Return}
936 @return: C{None}
937 """
938 try:
939 retval = self._dll.addRecord(info, pFun=pFun)
940 except APIException, e:
941 self.fail(e)
942 except FunctionException, e:
943 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
944 self.assertTrue(e.getRetval() == result, msg=msg)
945
947 """
948 Execute the C{insertRecord} method, asserts that there are no
949 C{APIException} or C{FunctionException} exceptions, and asserts that
950 the return code is correct.
951
952 @param info: An instance of the C{Info} class.
953 @type info: C{Info}
954 @param dir: The direction to insert indicator.
955 @type dir: C{InsertDir}
956 @keyword result: The expected value, the default is C{Return.NORMAL}.
957 @type result: C{Return}
958 @return: C{None}
959 """
960 try:
961 retval = self._dll.insertRecord(info, dir)
962 except APIException, e:
963 self.fail(e)
964 except FunctionException, e:
965 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
966 self.assertTrue(e.getRetval() == result, msg=msg)
967
969 """
970 Execute the C{swapRecord} method, asserts that there are no
971 C{APIException} or C{FunctionException} exceptions, and asserts that
972 the return code is correct.
973
974 @param dir: The direction to swap indicator.
975 @type dir: C{InsertDir}
976 @keyword result: The expected value, the default is C{Return.NORMAL}.
977 @type result: C{Return}
978 @return: C{None}
979 """
980 try:
981 retval = self._dll.swapRecord(dir)
982 except APIException, e:
983 self.fail(e)
984 except FunctionException, e:
985 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
986 self.assertTrue(e.getRetval() == result, msg=msg)
987
989 """
990 Execute the C{updateCurrentRecord} method, asserts that there are no
991 C{APIException} or C{FunctionException} exceptions, and asserts that
992 the return code is correct.
993
994 @param record: Will contains the results of the get.
995 @type record: C{Info}
996 @keyword result: The expected value, the default is C{Return.NORMAL}.
997 @type result: C{Return}
998 @return: C{None}
999 """
1000 try:
1001 retval = self._dll.updateCurrentRecord(record)
1002 except APIException, e:
1003 self.fail(e)
1004 except FunctionException, e:
1005 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1006 self.assertTrue(e.getRetval() == result, msg=msg)
1007
1009 """
1010 Execute the C{} method, asserts that there are no
1011 C{APIException} or C{FunctionException} exceptions, and asserts that
1012 the return code is correct.
1013
1014 @keyword result: The expected value, the default is C{Return.NORMAL}.
1015 @type result: C{Return}
1016 @return: C{None}
1017 """
1018 try:
1019 retval = self._dll.deleteCurrentRecord()
1020 except APIException, e:
1021 self.fail(e)
1022 except FunctionException, e:
1023 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1024 self.assertTrue(e.getRetval() == result, msg=msg)
1025
1027 """
1028 Execute the C{deleteAllNodes} method, asserts that there are no
1029 C{APIException} or C{FunctionException} exceptions, and asserts that
1030 the return code is correct.
1031
1032 @keyword result: The expected value, the default is C{Return.NORMAL}.
1033 @type result: C{Return}
1034 @return: C{None}
1035 """
1036 try:
1037 retval = self._dll.deleteAllNodes()
1038 except APIException, e:
1039 self.fail(e)
1040 except FunctionException, e:
1041 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1042 self.assertTrue(e.getRetval() == result, msg=msg)
1043
1045 """
1046 Execute the C{findRecord} method, asserts that there are no
1047 C{APIException} or C{FunctionException} exceptions, assert that the
1048 test value is correct, and asserts that the return code is correct.
1049
1050 @param record: Will contain the results of the find.
1051 @type record: C{Info}
1052 @param match: Provides the query information.
1053 @type match: C{Info}
1054 @keyword pFun: An optional compare function, the default is C{None}.
1055 @type pFun: C{ctypes CFUNCTYPE}
1056 @keyword result: The expected value, the default is C{Return.NORMAL}.
1057 @type result: C{Return}
1058 @return: C{None}
1059 """
1060 try:
1061 retval = self._dll.findRecord(record, match, pFun=pFun)
1062 except APIException, e:
1063 self.fail(e)
1064 except FunctionException, e:
1065 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1066 self.assertTrue(e.getRetval() == result, msg=msg)
1067
1068 msg = "record.value: %s, match.value: %s" % (record.value, match.value)
1069 self.assertTrue(record.value == match.value or
1070 result == Return.NOT_FOUND, msg=msg)
1071
1073 """
1074 Execute the C{findNthRecord} method, asserts that there are no
1075 C{APIException} or C{FunctionException} exceptions, assert that the
1076 test value is correct, and asserts that the return code is correct.
1077
1078 @param record: Will contain the results of the find.
1079 @type record: C{Info}
1080 @param skip: The number of records to skip over.
1081 @type skip: C{int}
1082 @keyword test: Value to test, default is an empty string.
1083 @type test: C{str}
1084 @keyword result: The expected value, the default is C{Return.NORMAL}.
1085 @type result: C{Return}
1086 @return: C{None}
1087 """
1088 try:
1089 retval = self._dll.findNthRecord(record, skip)
1090 except APIException, e:
1091 self.fail(e)
1092 except FunctionException, e:
1093 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1094 self.assertTrue(e.getRetval() == result, msg=msg)
1095
1096
1097 msg = "record.value: %s, test: %s" % (record.value, test)
1098 self.assertTrue(record.value == test or
1099 result == Return.NOT_FOUND, msg=msg)
1100
1102 """
1103 Execute the C{getCurrentRecord} method, asserts that there are no
1104 C{APIException} or C{FunctionException} exceptions, assert that the
1105 test value is correct, and asserts that the return code is correct.
1106
1107 @param record: Will contain the results of the find.
1108 @type record: C{Info}
1109 @keyword test: Value to test, default is an empty string.
1110 @type test: C{str}
1111 @keyword result: The expected value, the default is C{Return.NORMAL}.
1112 @type result: C{Return}
1113 @return: C{None}
1114 """
1115 try:
1116 retval = self._dll.getCurrentRecord(record)
1117 except APIException, e:
1118 self.fail(e)
1119 except FunctionException, e:
1120 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1121 self.assertTrue(e.getRetval() == result, msg=msg)
1122
1123 msg = "record.value: %s, test: %s" % (record.value, test)
1124 self.assertTrue(test == record.value, msg=msg)
1125
1127 """
1128 Execute the C{getPriorRecord} method, asserts that there are no
1129 C{APIException} or C{FunctionException} exceptions, assert that the
1130 test value is correct, and asserts that the return code is correct.
1131
1132 @param record: Will contain the results of the find.
1133 @type record: C{Info}
1134 @keyword test: Value to test, default is an empty string.
1135 @type test: C{str}
1136 @keyword result: The expected value, the default is C{Return.NORMAL}.
1137 @type result: C{Return}
1138 @return: C{None}
1139 """
1140 try:
1141 retval = self._dll.getPriorRecord(record)
1142 except APIException, e:
1143 self.fail(e)
1144 except FunctionException, e:
1145 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1146 self.assertTrue(e.getRetval() == result, msg=msg)
1147
1148 msg = "record.value: %s, test: %s" % (record.value, test)
1149 self.assertTrue(test == record.value, msg=msg)
1150
1152 """
1153 Execute the C{getNextRecord} method, asserts that there are no
1154 C{APIException} or C{FunctionException} exceptions, assert that the
1155 test value is correct, and asserts that the return code is correct.
1156
1157 @param record: Will contain the results of the find.
1158 @type record: C{Info}
1159 @keyword test: Value to test, default is an empty string.
1160 @type test: C{str}
1161 @keyword result: The expected value, the default is C{Return.NORMAL}.
1162 @type result: C{Return}
1163 @return: C{None}
1164 """
1165 try:
1166 retval = self._dll.getNextRecord(record)
1167 except APIException, e:
1168 self.fail(e)
1169 except FunctionException, e:
1170 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1171 self.assertTrue(e.getRetval() == result, msg=msg)
1172
1173 msg = "record.value: %s, test: %s" % (record.value, test)
1174 self.assertTrue(test == record.value, msg=msg)
1175
1177 """
1178 Execute the C{saveList} method, asserts that there are no
1179 C{APIException} or C{FunctionException} exceptions, and asserts that
1180 the return code is correct.
1181
1182 @param path: The full path to the data file.
1183 @type path: C{str}
1184 @keyword result: The expected value, the default is C{Return.NORMAL}.
1185 @type result: C{Return}
1186 @return: C{None}
1187 """
1188 try:
1189 retval = self._dll.saveList(path)
1190 except APIException, e:
1191 self.fail(e)
1192 except FunctionException, e:
1193 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1194 self.assertTrue(e.getRetval() == result, msg=msg)
1195
1197 """
1198 Execute the C{loadList} method, asserts that there are no
1199 C{APIException} or C{FunctionException} exceptions, and asserts that
1200 the return code is correct.
1201
1202 @param path: The full path to the data file.
1203 @type path: C{str}
1204 @keyword pFun: An optional compare function, the default is C{None}.
1205 @type pFun: C{ctypes CFUNCTYPE}
1206 @keyword result: The expected value, the default is C{Return.NORMAL}.
1207 @type result: C{Return}
1208 @return: C{None}
1209 """
1210 try:
1211 retval = self._dll.loadList(path, pFun=pFun)
1212 except APIException, e:
1213 self.fail(e)
1214 except FunctionException, e:
1215 msg = "Return.%s: %s" % Return.getMessage(e.getRetval())
1216 self.assertTrue(e.getRetval() == result, msg=msg)
1217
1218
1219 if __name__ == '__main__':
1220 unittest.main()
1221