def test_upload_and_delete_entries(self): self.addCleanup(self.delete_default_table_and_check) self.create_default_table_and_check() entries = [{'id': idx, 'name': 'some_name', 'amount': idx} for idx in range(10)] api.upload_entries(client=self.client, table_name=self.default_table_name, entries=entries) instance_entries = api.query_entries(self.client, self.default_table_name) self.assertEqual(instance_entries, entries) api.delete_entries(client=self.client, query={'from': self.default_table_name, 'where': {'id': {'$gte': 5}}}) instance_entries = api.query_entries(self.client, self.default_table_name) self.assertEqual(instance_entries, entries[:5])
def compare_table_entries_to_file_content(self, table_name: str, exp_file_path: Path, compare_order: bool = False): table_entries = query_entries(self.client, table_name) with exp_file_path.open() as exp_f: file_content = json.load(exp_f) if compare_order: self.assertEqual(table_entries, file_content) else: self.assertCountEqual(table_entries, file_content)
def test_upload_data_from_query(self): self.create_table() self.parse_and_execute_upload_data_from_query() result_table_entries = query_entries(self.client, self.default_table_name) with (self.input_folder / 'invoice_no_null_value.json').open() as exp_f: self.assertCountEqual(result_table_entries, json.load(exp_f))
def test_quick_add_table_from_query(self): self.parse_and_execute_quick_add_table() result_table_entries = query_entries(self.client, self.default_table_name) with (self.input_folder / 'invoice_no_null_value_lower_case_columns.json').open() as exp_f: self.assertCountEqual(result_table_entries, json.load(exp_f))
def query_table_all_entries_step(self, expected_result): entries = api.query_entries(self.client, self.default_table_name) self.assertEqual(len(entries), expected_result)
def query_table_entries_step(self): entries = api.query_entries(self.client, self.default_table_name, 2, 2) self.assertEqual(entries, [ {'id': 2, 'name': 'some_name', 'amount': 2}, {'id': 3, 'name': 'some_name', 'amount': 3} ])