示例#1
0
 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)
示例#2
0
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
示例#3
0
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)
示例#4
0
def insert_alert_table(owner_name, error_amount, alert_needed):
    Alert(owner_name=owner_name,
          error_amount=error_amount,
          alert_needed=alert_needed)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
 def setUp(self):
     self.owner_name = u'Виктория Fantasy'
     Alert.select().delete(bulk=True)
示例#8
0
 def setUp(self):
     Alert.select().delete(bulk=True)