blob: 72f506fb55fd0b65c873fc5fdfa8396b6ef5cbe3 [file] [log] [blame] [view]
# Local Agent Tests
This folder contains unit and functional (integration with backend) tests for Local Agent.
You'll have to install the extra packages to run the tests:
```
$ source <venv-name>/bin/activate
$ cd /path/to/{repo-base}/local-agent
$ pip install .[test]
```
## Unit Test
Run all the unit tests and show the coverage report.
1. Activate the virtual environment.
2. Execute the coverage tool:
```
cd /path/to/{repo-base}/local-agent/local_agent/tests/unit_tests/
coverage run --source={LOCAL_AGENT_PACKAGE_PATH}/local_agent/ -m unittest discover && coverage report
```
where {LOCAL_AGENT_PACKAGE_PATH} can be obtained by the following command:
```
$ pip show local-agent | grep -e "^Location" | awk -F " " '{print $2}'
```
## Real AMS Test
```Important```: If you're NOT an internal Googler or tester, you won't be able to run this test.
Run the local agent with a real Test Suite Backend (AMS).
1. Backend setup: If you're an internal Googler or tester, please contact the local agent author for the backend deployment; Otherwise, you won't be able to deploy the backend.
2. Edit the local agent config file: filling the ```AMS_HOST``` and ```AMS_PORT``` fields with the AMS configurations. Contact the local agent author if you're not sure about the backend configurations. See ```example_config.yaml``` for references.
3. Activate the virtual environment.
4. Connect your Matter devices with the above mentioned testabilities to the host machine. (You can still run the AMS test without connecting any devices).
5. Start the fake front end process \
Use ```-host [tsb_host]``` and ```-port [tsb_port]``` to indicate the host and port of deployed backend, the fake front end will use ```host=localhost``` and ```port=8000``` if the arguments are not provided. \
For example: \
Run with real devices
```
python fake_front_end.py
```
6. Start the local agent process:
```
local-agent -u [config file location]
```
or just put the config under ```~/.config/google/local_agent_config.yaml```, then start the process parameterlessly:
```
local-agent
```
7. The Local Agent should prompt the user for entering the linking code, which is displayed in the console of ```fake_front_end``` process.