Set Up
- Check out the code into your local repo
- Pip install PyYAML, requests, pdoc3, unittest
- Set up servers for testing
- PySense tests must be run as admin
- Create configuration files in Test/resources
- Files to create
- TestConfig.yaml: All non version specific methods will be run against this file
- WindowsConfig.yaml: Create if you want to test Windows only end points
- LinuxConfig.yaml: Create if you want to test Linux only end points.
- Note:
- If your TestConfig is Linux, you can copy that config to LinuxConfig.yaml. Same with Windows.
- Files to create
- Import PySense.smodel to all servers being tested against
- Attach the CSV file to Dim_Dates.csv
- Build the cube on both instances
- All other assets needed are created and destroyed by the test
- Run a test ensure all tests pass
- The linux build one and data import may fail due to API issues
Repo walk through
- Documentation
- This is the folder where the html documentation is stored
- Documentation is created from function comments (so comment your functions)
- Regenerate it with pdoc after before every release
- Html is viewed through link in readme
- Sample pdoc run:
"venv/Scripts/pdoc3.exe" --html --output-dir Documentation PySense
- PySense Tutorial: Contains assets relating to PySense training series
- PySense: The actual code, which we will cover below
- Scripts:
- Sample scripts for users to use
- When adding a new script
- Ensure comment at the top explaining script
- Separated block of configuration options that can be set
- Scripts should be runnable with no configuration beyond this
- Snippets: Example one liners on how to use functions
- Tests
- PySense tests tests all method called from py_client
- PySense{some object}Tests has all the tests for that object
- PySense{os}Tests has tests for platform specific methods
- All tests are added to the scale_test_suite
- In the main function we set up and tear down our test assets
- Test assets that should be reused are put in resources
- Test assets that are ephemeral are put in tmp
- Other
- Git attributes: Used so that git doesn’t count the documentation html as “code”
- Git ignore: For ignoring files we don’t want to commit to git
- Installing Python pptx: A walk through on installing python
- Licence: PySense uses the GPL-3.0 License
- ReleaseNotesFull.md:
- A running list of release notes for all versions
- When creating a new release append the new release notes to the top
- Readme.md: The current github readme
- Setup.py: A file to tell pypi about PySense
The Code (PySense Folder)
- PySense MixIns
- Contains functions that need to be accessible from py_client
- Done to prevent PySense.py from becoming too large
- PySense.py
- Set up all authentication methods
- Authentication methods all get forwarded to PySenseAuthentication class for processing
- Authentication methods return the py_client object
- We add all of our mixins to PySense
- init
- Creates a py_client that links us to server
- Param dict allows users to pass in their own config values
- There is a default dict which contains some default values
- Users can overwrite this by passing the value in a parameter
- Create the rest connector object
- Initializes role values
- Methods for modifying debug and parameter settings
- Set up all authentication methods
- PySenseAuthentication.py: Authentication methods
- PySense{object}.py
- The python class for each PySense object
- Each object has
- A reference to py_client so it knows what server it belongs to
- An internal copy of it’s json
- Methods for manipulating that object
- PySenseRestConnector.py
- The rest wrapper around PySense
- Use rest_call to make a call to the api
- Action_type: post, put, get, patch, delete
- Url: the api url, ex: ‘api/v1/dashboards’
- Data: Data payload if needed
- Json_payload: Json_payload, more likely to be used
- Query_params
- A json dict of query params
- PySense will format them into a query string
- PySense will remove any keys with value ‘None’
- File: A file to upload (like an sdata file)
- Path: A place to download the response, like for exporting
- SisenseRole.py
- Enum which defines roles in PySense
- Done to reduce confusion around role names in PySense
- Can convert a string to a role enum with from_str()
- SisenseVersion.py: Enum for defining linux or windows