Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds expectation for deleted entities #317

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

kena-SL
Copy link
Contributor

@kena-SL kena-SL commented Jan 21, 2025

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This PR creates an expectation to identify and return deleted entities for datasets.

The implementation follows these steps:

Fetch Active Resources: Retrieve the list of active resources for a given organisation.
Identify Active Entities: Gather the active entities associated with each resource.
Compare Entities: Compare the entities from the platform with those on the active resource.

If an entity exists on the platform but not in the active resource, it is flagged as deleted.

The entity numbers identified as deleted are returned in the results.

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Please replace this line with instructions on how to test your changes, a note
on the devices and browsers this has been tested on, as well as any relevant
images for UI changes.

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above. Please refer to the Digital Land Testing Guidance for more information.

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

[optional] Are there any post deployment tasks we need to perform?

[optional] Are there any dependencies on other PRs or Work?

@kena-SL kena-SL requested a review from alexglasertpx January 21, 2025 14:35

# mock `pandas.read_csv` to return the mock DataFrame
mock_df = pd.DataFrame({"resource": ["2f7d900dd48fd02"]})
mocker.patch("pandas.read_csv", return_value=mock_df)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these lines necessary? I can't see where 'mock_df' is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setup mocks the read_csv() function, which is used to fetch resource data from the digital-land database.
Since pd.read_csv(base_url) returns a DataFrame, the mock_df is used to replicate that behaviour.

# get dataset specific active resource list
params = urllib.parse.urlencode(
{
"sql": f"""select *,o.entity from reporting_historic_endpoints rhe join organisation o on rhe.organisation=o.organisation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 'select *,o.entity ...' should there be an alias in front of the star or is 'o.entity' not required as the star will bring all of the columns in?

test_fact_resource_data.to_sql(
"fact_resource", conn, if_exists="append", index=False
)
test_fact_data.to_sql("fact", conn, if_exists="append", index=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want the if_exists to be 'replace' as the tables are only meant for testing purposes it might append extra rows to a test table?

@kena-SL kena-SL merged commit 9130178 into main Jan 22, 2025
3 checks passed
@kena-SL kena-SL deleted the feat/deleted-entities-expectation branch January 22, 2025 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants