Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

I need to verify if the record is present in yjr temporary table (TMP_BSF_BOOT_STRAP) [closed]

$
0
0

I'm trying to create a feature to validate that the temporary table (TMP_BSF_BOOT_STRAP in my case) contains some data. But while trying to do it I've bumped into the following exception:

  File "steps/behave.py", line 107, in step_impl    context.tmp_result=context.TMP_Table  File "/home/ec2-user/.local/lib/python3.8/site-packages/behave/runner.py", line 321, in __getattr__    raise AttributeError(msg)AttributeError: 'Context' object has no attribute 'TMP_Table'

Feature file:

  Scenario: Validate TMP table contains the added record    Given the TMP table is set up    When I perform some actions to add a record    Then validate TMP table should contain the added record with the current imsi

Step functions:

@given('the TMP table is set up')def step_impl(context):    context.tmp_table = TMP_Table()@when('I perform some actions to add a record')def step_impl(context):    # Implement the actions to add a record to the TMP table    # This could involve interacting with your application or database    pass@then('validate TMP table should contain the added record with the current imsi')def step_impl(context):    context.tmp_result=context.TMP_Table    assert context.tmp_table.contains_record(record_values), "Record not found in TMP table"

This is the code that works with the temporary table:

import pandas as pdclass TMP_Table:    def __init__(self):        # Initialize TMP table or connect to the database if needed        pass    def contains_record(self, record_values):        # Implement the logic to check if the record exists in TMP table        # You may need to query your TMP table or perform any necessary checks        # For demonstration purposes, checking if IMSI is present in TMP table        return record_values["IMSI"] in self.get_imsi_list_from_tmp_table()    def get_imsi_list_from_tmp_table(self):        # Implement the logic to fetch IMSI values from TMP table        # This could involve querying the database or any other data source        # For demonstration purposes, returning a static list        return ["901280064473398"]    def validate_tmp_table(self, csv_file_path, testcase_id, tmp_table):        csv_file_path = '/home/ec2-user/environment/bsf_test_automtion/features/test_data/tmp_table.csv'        tmp_table = TMP_Table()        df = pd.read_csv(csv_file_path)        testcase_df = df[df['SLNO'] == int(testcase_id)]        if not testcase_df.empty:            record_values = testcase_df.iloc[0].to_dict()            if tmp_table.contains_record(record_values):                print("TMP table contains the added record for the specified testcase.")            else:                print("Record not found in TMP table.")        else:            print(f"Testcase with ID {testcase_id} not found in CSV file {csv_file_path}")

Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>