def testNoEndTime(self): plugin = HistoryPlugin("0001", "0001", "example_product", "no image") event_package1 = Monitor(event_type = MonitorType.TEST_PACKAGE_STARTED, sender = "ots-worker1", description = "test-noenddata-tests") plugin.add_monitor_event(event_package1) plugin.set_tested_packages({"env" : ["test-noenddata-tests"]}) plugin.publish() db_package = Package.objects.filter(package_name = "test-noenddata-tests") self.assertTrue(db_package.count() == 0)
def testNoEndTime(self): plugin = HistoryPlugin("0001", "0001", "example_product", "no image") event_package1 = Monitor(event_type=MonitorType.TEST_PACKAGE_STARTED, sender="ots-worker1", description="test-noenddata-tests") plugin.add_monitor_event(event_package1) plugin.set_tested_packages({"env": ["test-noenddata-tests"]}) plugin.publish() db_package = Package.objects.filter( package_name="test-noenddata-tests") self.assertTrue(db_package.count() == 0)
def testCreateNew(self): plugin = HistoryPlugin("0001", "0001", "example_product", "no image") event_package1 = Monitor(event_type = MonitorType.TEST_PACKAGE_STARTED, sender = "ots-worker1", description = "test-newpackage-tests") plugin.add_monitor_event(event_package1) time.sleep(1) event_package1 = Monitor(event_type = MonitorType.TEST_PACKAGE_ENDED, sender = "ots-worker1", description = "test-newpackage-tests") plugin.add_monitor_event(event_package1) plugin.set_tested_packages({"env" : ["test-newpackage-tests"]}) plugin.publish() db_package = Package.objects.filter(package_name = "test-newpackage-tests") history = History.objects.filter(package_id = db_package[0].id) self.assertTrue(db_package.count() == 1) self.assertTrue(history.count() == 1) self.assertTrue(history[0].duration >= 1)
def testAddToOld(self): plugin = HistoryPlugin("0001", "0001", "example_product", "no image") event_package1 = Monitor(event_type=MonitorType.TEST_PACKAGE_STARTED, sender="ots-worker1", description="test-package1-tests") plugin.add_monitor_event(event_package1) event_package1 = Monitor(event_type=MonitorType.TEST_PACKAGE_ENDED, sender="ots-worker1", description="test-package1-tests") plugin.add_monitor_event(event_package1) plugin.set_tested_packages({"env": ["test-package1-tests"]}) plugin.publish() db_package = Package.objects.filter(package_name="test-package1-tests") history = History.objects.filter(package_id=db_package[0].id) self.assertTrue(db_package.count() == 1) self.assertTrue(history.count() == 2)