CCI-MOC / openstack-billing-from-db

Simple billing from the database
Apache License 2.0
1 stars 3 forks source link

Refactored SU Flavor logic #64

Open QuanMPhm opened 1 month ago

QuanMPhm commented 1 month ago

Closes #57. The Flavor object will no longer require an SU name. The SU type will be determined only from PCI requests.

QuanMPhm commented 1 month ago

@knikolla I'm a bit unsure about how to write a test case for this PR. From what I understand, because I want to test the correctness of my code, do I make test cases around calling collect_invoice_data_from_openstack() and Database.get_instances(), since those are the functions that are changed?

knikolla commented 1 month ago

@knikolla I'm a bit unsure about how to write a test case for this PR. From what I understand, because I want to test the correctness of my code, do I make test cases around calling collect_invoice_data_from_openstack() and Database.get_instances(), since those are the functions that are changed?

The service unit type is detected from the contents of pci_requests right? You can split out that part into a separate function and see that it detects the appropriate service unit types based on the provided pci_request that you are crafting.

Similarly, the function that sums up based on flavor type, does it based on the su type value.

So the trick to testing this is to split out as a separate what can be written as a separate function and that doesn't have dependencies on external systems.

QuanMPhm commented 2 weeks ago

@naved001 I've applied your comments, and renamed the count variable to gpu_count for clarity.