def test_update_exists_record(self): dbcmd.insert_alert_table(self.owner_name, 15, False) dbcmd.update_alert_table(self.owner_name, 10, True) a = Alert.get(owner_name=self.owner_name) alert_results = (a.owner_name, a.error_amount, a.alert_needed) expected_results = (self.owner_name, 10, True) self.assertEqual(alert_results, expected_results)
def update_alert_table(owner_name, error_amount, alert_needed): alert_data = Alert.get(owner_name=owner_name) if alert_data is None: insert_alert_table(owner_name, error_amount, alert_needed) return alert_data.error_amount = error_amount alert_data.alert_needed = alert_needed
def get_alert_data(owner_name): alert_data = Alert.get(owner_name=owner_name) if alert_data is None: return (None, None) return (alert_data.error_amount, alert_data.alert_needed)
def insert_alert_table(owner_name, error_amount, alert_needed): Alert(owner_name=owner_name, error_amount=error_amount, alert_needed=alert_needed)
def test_update_empty_record(self): dbcmd.update_alert_table(self.owner_name, 20, True) a = Alert.get(owner_name=self.owner_name) self.assertNotEqual(a, None)
def test_insert(self): dbcmd.insert_alert_table(self.owner_name, 10, True) a = Alert.get(owner_name=self.owner_name) alert_results = (a.owner_name, a.error_amount, a.alert_needed) expected_results = (self.owner_name, 10, True) self.assertEqual(alert_results, expected_results)
def setUp(self): self.owner_name = u'Виктория Fantasy' Alert.select().delete(bulk=True)
def setUp(self): Alert.select().delete(bulk=True)