示例#1
0
 def test_after_upsert_database_has_new_datapoint_after_it_has_been_inserted(
         self):
     condition = clientdb.strip_value(self.dp_new_raw)
     clientdb.upsert_one(self.session_factory, condition,
                         self.dp_new_raw["value"])
     result = clientdb.find_by(self.session_factory, condition)
     assert len(result) == 1 and result[0].value == self.dp_new_raw["value"]
示例#2
0
 def test_after_update_row_has_new_value(self):
     # update 1 row with specified data
     condition = clientdb.strip_value(self.dp1_raw_with_updated_value)
     clientdb.update_one(self.session_factory, condition,
                         self.dp1_raw_with_updated_value["value"])
     # tests that the specified row has "new" value after update
     result = clientdb.find_by(self.session_factory, condition)
     assert len(result) == 1 and result[
         0].value == self.dp1_raw_with_updated_value["value"]
示例#3
0
 def test_filled_database_has_two_rows_only(self):
     result = clientdb.find_by(self.session_factory)
     assert len(result) == 2
示例#4
0
 def test_after_delete_one_row_database_has_one_row(self):
     condition = clientdb.strip_value(self.dp2_raw)
     clientdb.delete_one(self.session_factory, condition)
     result = clientdb.find_by(self.session_factory)
     assert len(result) == 1
示例#5
0
 def test_before_delete_database_has_two_rows(self):
     result = clientdb.find_by(self.session_factory)
     assert len(result) == 2
示例#6
0
 def test_database_has_new_datapoint_after_it_has_been_inserted(self):
     clientdb.insert_one(self.session_factory, self.dp_new)
     result = clientdb.find_by(self.session_factory, self.dp_new_raw)
     assert len(result) == 1 and result[0].value == self.dp_new_raw["value"]
示例#7
0
 def test_database_has_no_new_datapoint_which_has_not_been_inserted_yet(
         self):
     result = clientdb.find_by(self.session_factory, self.dp_new_raw)
     assert len(result) == 0
示例#8
0
 def test_before_update_row_has_old_value(self):
     condition = clientdb.strip_value(self.dp1_raw_with_updated_value)
     # tests that the specified row has "old" value before update
     result = clientdb.find_by(self.session_factory, condition)
     assert len(result) == 1 and result[
         0].value != self.dp1_raw_with_updated_value["value"]
示例#9
0
 def test_before_upsert_database_has_no_new_datapoint_which_has_not_been_inserted_yet(
         self):
     condition = clientdb.strip_value(self.dp_new_raw)
     result = clientdb.find_by(self.session_factory, condition)
     assert len(result) == 0
示例#10
0
 def test_after_upsert_the_old_row_has_new_value(self):
     condition = clientdb.strip_value(self.dp1_raw)
     clientdb.upsert_one(self.session_factory, condition,
                         self.dp1_updated_value)
     result = clientdb.find_by(self.session_factory, condition)
     assert len(result) == 1 and result[0].value == self.dp1_updated_value
示例#11
0
 def test_before_upsert_the_old_row_has_old_value(self):
     condition = clientdb.strip_value(self.dp1_raw)
     result = clientdb.find_by(self.session_factory, condition)
     assert len(result) == 1 and result[0].value != self.dp1_updated_value
示例#12
0
 def test_filled_database_has_specified_datapoint2(self):
     condition = clientdb.strip_value(self.dp2_raw)
     result = clientdb.find_by(self.session_factory, condition)
     assert len(result) == 1