ami-lab/AmI-Platform — pull request #206 by dianatatu (2013-06-21 12:08:53+00:00)
Title: Add pipeline tests using dump data

#### Need
Increase maintainability of all PDU's code

#### Solution

__1. Collect data dumps__

- [ ] `diana.txt`
- [ ] `diana_no_skeleton.txt`
- [ ] `andrei.txt`

__2. Pipeline tests__

```python
PDUs = [Router, HeadCrop]
DATA_FILE = '/tmp/diana_no_skeleton.txt'
def check_results(self):
"""Assert that HeadCrop PDU crops Diana's face using no skeleton data.
Check that 'face-recognition' queue has at least one message to be processed.
Check that HeadCrop called `_crop_head_using_face_detection`.
"""
```
---
```python
PDUs = [Router, HeadCrop]
DATA_FILE = '/tmp/diana.txt'
def check_results(self):
"""Assert that HeadCrop PDU crops Diana's face using skeleton+image data.
Check that 'face-recognition' queue has at least one message to be processed.
Check that HeadCrop called `_crop_head_using_skeleton`.
"""
```
---
```python
PDUs = [Router, HeadCrop, FaceRecognition]
DATA_FILE = '/tmp/diana.txt'
def check_results(self):
"""Assert that FaceRecognition PDU detects Diana's face.
Check that 'room' queue has at least one message to be processed.
This message should have the following content:
{
'person_name': 'diana@amilab.ro',
'event_type': 'person_appeared'
}
"""
```
---
```python
PDUs = [Router, HeadCrop, FaceRecognition]
DATA_FILE = '/tmp/andrei.txt'
def check_results(self):
"""Assert that FaceRecognition PDU detects Andrei's face.
Check that 'room' queue has at least one message to be processed.
This message should have the following content:
{
'person_name': 'andrei@amilab.ro',
'event_type': 'person_appeared'
}
"""
```
---
```python
PDUs = [Router, HeadCrop, FaceRecognition, Room]
DATA_FILE = '/tmp/diana.txt'
def check_results(self):
"""Assert that Room PDU commands turning the AC off and
IPPower PDU plays e message.
Check that 'ip-power' queue and 'text-to-speech' queues have
at least one message to be processed.
The 'ip-power' queue message should have the following content:
{
'cmd': 'off',
'ip': DONTCARE,
'output': '1',
}
This 'text-to-speech' should have the following content:
{
'text': 'Hello, Diana!'
}
"""
```
---
```python
PDUs = [Router, HeadCrop, FaceRecognition, Room]
DATA_FILE = '/tmp/andrei.txt'
def check_results(self):
"""Assert that Room PDU commands turning the AC on and
IPPower PDU plays e message.
Check that 'ip-power' queue and 'text-to-speech' queues have
at least one message to be processed.
The 'ip-power' queue message should have the following content:
{
'cmd': 'on',
'ip': DONTCARE,
'output': '1',
}
This 'text-to-speech' should have the following content:
{
'text': 'Hello, Andrei!'
}
"""
```

__3. Unit tests__
We may also use pipeline tests to ease formatting data from DATA_FILE to a PDU's message format. Some of these tests may already exist, but we need to have a full list of sane tests.
```python
def test_head_crop_process_message(self):
""" Read from IMAGES_FOLDERNAME and save all head images
to HEAD_CROPPED_IMAGES_FOLDERNAME.
Read from HEAD_CROPPED_IMAGES_FOLDERNAME and save all
images where a face was detected in DETECTED_FACE_IMAGES_FOLDERNAME,
where each image shoul have DETECTED_PERSON name.
"""
```