'Test the reporting with binary state.'

@patch('time.time')
def test_report_with_binary_state(self, mock_time):

    mock_time.return_value = 12345
    state = ha.State('domain.entity', STATE_ON, {'foo': 1.0})
    with mock.patch.object(self.gf, '_send_to_graphite') as mock_send:
        self.gf._report_attributes('entity', state)
        expected = ['ha.entity.foo    1.000000    12345', 'ha.entity.state    1.000000    12345']
        actual = mock_send.call_args_list[0][0][0].split('\n')
        self.assertEqual(sorted(expected), sorted(actual))
    state.state = STATE_OFF
    with mock.patch.object(self.gf, '_send_to_graphite') as mock_send:
        self.gf._report_attributes('entity', state)
        expected = ['ha.entity.foo    1.000000    12345', 'ha.entity.state    0.000000    12345']
        actual = mock_send.call_args_list[0][0][0].split('\n')
        self.assertEqual(sorted(expected), sorted(actual))
