Browse Source

Unittest BugFixes

master
Dirk Alders 3 years ago
parent
commit
8dfadea495
3 changed files with 16 additions and 31 deletions
  1. 13
    28
      jsonlog.py
  2. 2
    2
      module_status.py
  3. 1
    1
      run.py

+ 13
- 28
jsonlog.py View File

@@ -7,7 +7,7 @@ import os
7 7
 import subprocess
8 8
 
9 9
 import fstools
10
-from unittest.output import STATUS_AVAILABLE, STATUS_CHANGED, STATUS_CLEAN, STATUS_EXISTS, STATUS_IN_WORK, STATUS_MISSING, STATUS_OLD, STATUS_RELEASED, STATUS_UNKNOWN
10
+from unittest.output import STATUS_AVAILABLE, STATUS_CHANGED, STATUS_CLEAN, STATUS_EXISTS, STATUS_FAILED, STATUS_IN_WORK, STATUS_MISSING, STATUS_OLD, STATUS_RELEASED, STATUS_UNKNOWN
11 11
 
12 12
 JSONLOG_FNAME = 'unittest.json'
13 13
 
@@ -57,7 +57,7 @@ TOBI_DEPENDENCIES = "Dependencies"
57 57
 TOBI_DESCRIPTION = "Description"
58 58
 TOBI_NAME = "Name"
59 59
 TOBI_STATE = "State"
60
-TOBI_STATE_RELESED = 'Released'
60
+TOBI_STATE_RELEASED = 'Released'
61 61
 TOBI_STATE_IN_DEVELOPMENT = 'In development'
62 62
 TOBI_SUPP_INTERP = "Supported Interpreters"
63 63
 TOBI_VERSION = "Version"
@@ -123,11 +123,12 @@ def __get_release_state__(ut_folder, lib):
123 123
         return STATUS_MISSING
124 124
     else:
125 125
         ut_status = ut_data.get(MAIN_KEY_TESTOBJECT_INFO, {}).get(TOBI_STATE, 'unknown')
126
-        if 'released' in ut_status.lower():
126
+        if ut_status == TOBI_STATE_RELEASED:
127 127
             return STATUS_RELEASED
128
-        elif 'work' in ut_status.lower():
128
+        elif ut_status == TOBI_STATE_IN_DEVELOPMENT:
129 129
             return STATUS_IN_WORK
130 130
         else:
131
+            print(ut_status)
131 132
             return STATUS_UNKNOWN
132 133
 
133 134
 
@@ -155,7 +156,7 @@ def __get_testcase_integrity__(ut_folder, lib):
155 156
         if tc_version == current_version:
156 157
             return STATUS_CLEAN
157 158
         else:
158
-            return STATUS_CHANGED
159
+            return STATUS_IN_WORK
159 160
 
160 161
 
161 162
 def get_lib_testcase_integrity(ut_folder):
@@ -193,31 +194,15 @@ def get_ut_src_integrity(ut_folder):
193 194
     return __get_src_integrity__(ut_folder, False)
194 195
 
195 196
 
196
-def status_module(ut_folder):
197
-    try:
198
-        with open(get_lib_jsonlog(ut_folder), 'r') as fh:
199
-            ut_lib = json.loads(fh.read())
200
-    except IOError:
197
+def status_lib_unittest(ut_folder):
198
+    if get_lib_release_state(ut_folder) == STATUS_RELEASED and get_lib_src_integrity(ut_folder) == STATUS_CLEAN and get_lib_testcase_integrity(ut_folder) == STATUS_CLEAN:
199
+        return STATUS_CLEAN
200
+    elif get_lib_release_state(ut_folder) == STATUS_MISSING and get_lib_src_integrity(ut_folder) == STATUS_MISSING and get_lib_testcase_integrity(ut_folder) == STATUS_MISSING:
201 201
         return STATUS_MISSING
202
+    elif get_lib_release_state(ut_folder) == STATUS_IN_WORK or get_lib_src_integrity(ut_folder) == STATUS_IN_WORK or get_lib_testcase_integrity(ut_folder) == STATUS_IN_WORK:
203
+        return STATUS_IN_WORK
202 204
     else:
203
-        try:
204
-            with open(get_ut_jsonlog(ut_folder), 'r') as fh:
205
-                ut_ut = json.loads(fh.read())
206
-        except IOError:
207
-            return STATUS_UNKNOWN
208
-        else:
209
-            tested_version = ut_lib.get(MAIN_KEY_TESTOBJECT_INFO, {}).get(TOBI_VERSION)
210
-            current_version = module_uid(get_lib_folder(ut_folder))
211
-            if ut_ut[MAIN_KEY_TESTOBJECT_INFO] != ut_lib[MAIN_KEY_TESTOBJECT_INFO] or ut_ut[MAIN_KEY_UNITTEST_INFO] != ut_lib[MAIN_KEY_UNITTEST_INFO] or tested_version != current_version:
212
-                return STATUS_OLD
213
-            else:
214
-                ut_status = ut_lib.get(MAIN_KEY_TESTOBJECT_INFO, {}).get(TOBI_STATE, 'unknown')
215
-                if 'released' in ut_status.lower():
216
-                    return STATUS_RELEASED
217
-                elif 'work' in ut_status.lower():
218
-                    return STATUS_IN_WORK
219
-                else:
220
-                    return STATUS_UNKNOWN
205
+        return STATUS_UNKNOWN
221 206
 
222 207
 
223 208
 def versions_module(ut_folder):

+ 2
- 2
module_status.py View File

@@ -7,7 +7,7 @@ import os
7 7
 from unittest.output import termcolors, coverage_output
8 8
 
9 9
 from unittest.output import STATUS_COLORS, STATUS_UNKNOWN
10
-from unittest.jsonlog import lib_coverage, status_doc, status_git, status_module, status_spec, versions_module
10
+from unittest.jsonlog import lib_coverage, status_doc, status_git, status_lib_unittest, status_spec, versions_module
11 11
 
12 12
 STATUS_LENGTH = 13
13 13
 
@@ -37,7 +37,7 @@ def module_status_head():
37 37
 def module_status_line(ut_folder):
38 38
     rv = '%25s%s%s%s%s%s%s\n' % (
39 39
         os.path.basename(ut_folder) + ':',
40
-        status_output(status_module(ut_folder)),
40
+        status_output(status_lib_unittest(ut_folder)),
41 41
         status_output(status_doc(ut_folder)),
42 42
         status_output(versions_module(ut_folder), termcolors.BOLD),
43 43
         coverage_output(*lib_coverage(ut_folder), length=STATUS_LENGTH),

+ 1
- 1
run.py View File

@@ -225,7 +225,7 @@ def unittest_prepare(ut_folder):
225 225
     testobject_info[jsonlog.TOBI_VERSION] = jsonlog.module_uid(config.lib.__path__[0])
226 226
     testobject_info[jsonlog.TOBI_DESCRIPTION] = config.lib.__DESCRIPTION__
227 227
     testobject_info[jsonlog.TOBI_SUPP_INTERP] = ', '.join(['python%d' % vers for vers in config.lib.__INTERPRETER__])
228
-    testobject_info[jsonlog.TOBI_STATE] = jsonlog.TOBI_STATE_RELESED if config.release_unittest_version == unittest_info[jsonlog.UTEI_VERSION] else jsonlog.TOBI_STATE_IN_DEVELOPMENT
228
+    testobject_info[jsonlog.TOBI_STATE] = jsonlog.TOBI_STATE_RELEASED if config.release_unittest_version == unittest_info[jsonlog.UTEI_VERSION] else jsonlog.TOBI_STATE_IN_DEVELOPMENT
229 229
     testobject_info[jsonlog.TOBI_DEPENDENCIES] = []
230 230
     for dependency in config.lib.__DEPENDENCIES__:
231 231
         testobject_info[jsonlog.TOBI_DEPENDENCIES].append((dependency, jsonlog.module_uid(os.path.join(jsonlog.get_ut_src_folder(ut_folder), dependency))))

Loading…
Cancel
Save