# Path: sendinel/backend/bluetooth.py
# def set_connection_to_bluetooth(server_address):
# def get_discovered_devices(server_address):
# def send_vcal(server_address, mac, data):
# 
# Path: sendinel/backend/models.py
# class WayOfCommunication(models.Model):
#     """
#     Represent a possible Way of Communication like SMS
#     """
#     
#     name = models.CharField(max_length = 255, blank = False, null = False)
#     verbose_name = models.CharField(max_length = 255)
#     enabled = models.BooleanField()
#     can_send_immediately = models.BooleanField()
#     
#     def __unicode__(self):
#         return self.verbose_name
# 
# Path: sendinel/notifications/models.py
# class NotificationType(models.Model):
#     """
#     Represent an notification type like follow-up consultation.
#     """
#     
#     name = models.CharField(max_length = 255)
#     verbose_name = models.CharField(max_length = 255)
#     template = models.CharField(max_length = 255)
#     notify_immediately = models.BooleanField()
# 
#     def __unicode__(self):
#         return self.verbose_name
#     
#     @classmethod
#     def get_notification_type(cls, type_name):
#         """
#         Return the given NotificationType
#         """
#         
#         notification_type = NotificationType.objects.get(name = type_name)
#         
#         return notification_type


import json
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import Client
from sendinel.backend import bluetooth
from sendinel.backend.models import WayOfCommunication
from sendinel.notifications.models import NotificationType
        data = {'date': '2012-02-22',
                'phone_number': '0175685444',
                'way_of_communication': "3"}
        self.client.post(reverse('notifications_create', \
                kwargs = {"notification_type_name": notification_type.name }), data)
        
        self.assertTrue(self.client.session.has_key("notification"))
    
        old_send_vcal = bluetooth.send_vcal
             
        def return_true(val, val2, val3):
            return True
             
        bluetooth.send_vcal = return_true
        
        response = self.client.post(reverse("notifications_send"), {
                         "device_mac":"123456789"})
        
        self.assertEquals(response.status_code, 200)
        
        def return_false(val, val2, val3):
            return False
        
        bluetooth.send_vcal = return_false
        
        response = self.client.post(reverse("notifications_send"), {
                         "device_mac":"123456789"})
                         
        self.assertEquals(response.status_code, 500)
        

# Path: sendinel/backend/bluetooth.py
# def set_connection_to_bluetooth(server_address):
# def get_discovered_devices(server_address):
# def send_vcal(server_address, mac, data):
# 
# Path: sendinel/backend/models.py
# class WayOfCommunication(models.Model):
#     """
#     Represent a possible Way of Communication like SMS
#     """
#     
#     name = models.CharField(max_length = 255, blank = False, null = False)
#     verbose_name = models.CharField(max_length = 255)
#     enabled = models.BooleanField()
#     can_send_immediately = models.BooleanField()
#     
#     def __unicode__(self):
#         return self.verbose_name
# 
# Path: sendinel/notifications/models.py
# class NotificationType(models.Model):
#     """
#     Represent an notification type like follow-up consultation.
#     """
#     
#     name = models.CharField(max_length = 255)
#     verbose_name = models.CharField(max_length = 255)
#     template = models.CharField(max_length = 255)
#     notify_immediately = models.BooleanField()
# 
#     def __unicode__(self):
#         return self.verbose_name
#     
#     @classmethod
#     def get_notification_type(cls, type_name):
#         """
#         Return the given NotificationType
#         """
#         
#         notification_type = NotificationType.objects.get(name = type_name)
#         
#         return notification_type


# Path: sendinel/web/tests/bluetooth_test.py
import json
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import Client
from sendinel.backend import bluetooth
from sendinel.backend.models import WayOfCommunication
from sendinel.notifications.models import NotificationType

        data = {'date': '2012-02-22',
                'phone_number': '0175685444',
                'way_of_communication': "3"}
        self.client.post(reverse('notifications_create', \
                kwargs = {"notification_type_name": notification_type.name }), data)
        
        self.assertTrue(self.client.session.has_key("notification"))
    
        old_send_vcal = bluetooth.send_vcal
             
        def return_true(val, val2, val3):
            return True
             
        bluetooth.send_vcal = return_true
        
        response = self.client.post(reverse("notifications_send"), {
                         "device_mac":"123456789"})
        
        self.assertEquals(response.status_code, 200)
        
        def return_false(val, val2, val3):
            return False
        
        bluetooth.send_vcal = return_false
        
        response = self.client.post(reverse("notifications_send"), {
                         "device_mac":"123456789"})
                         
        self.assertEquals(response.status_code, 500)
        

        bluetooth.send_vcal = old_send_vcal