def test_get_timestamp_returns_timestamp_field(self): timestamp = datetime.datetime(1970, 1, 1, 4, 30) timestamp -= datetime.timedelta(seconds=time.timezone) line = version_1.status_line(0, "GOOD", "subdir", "testname", "reason text", {"timestamp": "16200"}) self.assertEquals(timestamp, line.get_timestamp())
def test_get_kernel_returns_unknown_with_no_kernel(self): line = version_1.status_line(0, "GOOD", "subdir", "testname", "reason text", {"patch0": "first_patch 0 0", "patch2": "another_patch 0 0"}) kern = line.get_kernel() self.assertEquals(kern.base, "UNKNOWN") self.assertEquals(kern.patches, []) self.assertEquals(kern.kernel_hash, "UNKNOWN")
def test_get_kernel_ignores_out_of_sequence_patches(self): line = version_1.status_line(0, "GOOD", "subdir", "testname", "reason text", {"kernel": "2.6.24-rc40", "patch0": "first_patch 0 0", "patch2": "another_patch 0 0"}) kern = line.get_kernel() kernel_hash = utils.hash("md5", "2.6.24-rc40,0").hexdigest() self.assertEquals(kern.base, "2.6.24-rc40") self.assertEquals(kern.patches[0].spec, "first_patch") self.assertEquals(len(kern.patches), 1) self.assertEquals(kern.kernel_hash, kernel_hash)
def test_saves_all_fields(self): line = version_1.status_line(5, "GOOD", "subdir_name", "test_name", "my reason here", {"key1": "value", "key2": "another value", "key3": "value3"}) self.assertEquals(line.indent, 5) self.assertEquals(line.status, "GOOD") self.assertEquals(line.subdir, "subdir_name") self.assertEquals(line.testname, "test_name") self.assertEquals(line.reason, "my reason here") self.assertEquals(line.optional_fields, {"key1": "value", "key2": "another value", "key3": "value3"})
def test_get_kernel_returns_kernel_plus_patches(self): line = version_1.status_line( 0, "GOOD", "subdir", "testname", "reason text", { "kernel": "2.6.24-rc40", "patch0": "first_patch 0 0", "patch1": "another_patch 0 0" }) kern = line.get_kernel() kernel_hash = utils.hash("md5", "2.6.24-rc40,0,0").hexdigest() self.assertEqual(kern.base, "2.6.24-rc40") self.assertEqual(kern.patches[0].spec, "first_patch") self.assertEqual(kern.patches[1].spec, "another_patch") self.assertEqual(len(kern.patches), 2) self.assertEqual(kern.kernel_hash, kernel_hash)
def test_bad_reboot_passes_success_test(self): line = version_1.status_line(0, "NOSTATUS", None, "reboot", "reboot success", {}) self.assertEquals(line.is_successful_reboot("FAIL"), False) self.assertEquals(line.is_successful_reboot("ABORT"), False)
def test_good_reboot_passes_success_test(self): line = version_1.status_line(0, "NOSTATUS", None, "reboot", "reboot success", {}) self.assertEquals(line.is_successful_reboot("GOOD"), True) self.assertEquals(line.is_successful_reboot("WARN"), True)
def test_parses_blank_testname(self): line = version_1.status_line(0, "GOOD", "subdir", "----", "", {}) self.assertEquals(line.testname, None)
def test_parses_blank_subdir(self): line = version_1.status_line(0, "GOOD", "----", "test", "", {}) self.assertEquals(line.subdir, None)
def test_handles_endstatus(self): for stat in self.statuses: line = version_1.status_line(0, "END " + stat, "----", "test", "", {}) self.assertEquals(line.type, "END") self.assertEquals(line.status, stat)
def test_handles_info(self): line = version_1.status_line(0, "INFO", "----", "----", "", {}) self.assertEquals(line.type, "INFO") self.assertEquals(line.status, None)
def test_handles_start(self): line = version_1.status_line(0, "START", "----", "test", "", {}) self.assertEquals(line.type, "START") self.assertEquals(line.status, None)
def test_get_timestamp_returns_none_on_missing_field(self): line = version_1.status_line(0, "GOOD", "subdir", "testname", "reason text", {}) self.assertEquals(None, line.get_timestamp())
def test_handles_status(self): for stat in self.statuses: line = version_1.status_line(0, stat, "----", "test", "", {}) self.assertEqual(line.type, "STATUS") self.assertEqual(line.status, stat)