# 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
            device_dict = {}
            device_dict[first_mac] = first_value
            device_dict[second_mac] = second_value
            return device_dict
        bluetooth.get_discovered_devices = new_get_discovered_devices
        
        response = self.client.post("/web/get_devices/")
        self.failUnlessEqual(response.status_code, 200)
        self.assertEquals(response["Content-Type"], "application/json")
        
        dict = json.loads(response.content)
        self.assertTrue(dict.has_key("devices"))
        array_devices = dict["devices"]
        
        self.assertEquals(len(array_devices), 2)
        self.assertTrue(array_devices[0].has_key("mac"))
        self.assertTrue(array_devices[0].has_key("name"))
        self.assertTrue(array_devices[0]["mac"] in valid_macs)
        self.assertTrue(array_devices[0]["name"] in valid_values)
        self.assertTrue(array_devices[1].has_key("mac"))
        self.assertTrue(array_devices[1].has_key("name"))
        self.assertTrue(array_devices[1]["mac"] in valid_macs)
        self.assertTrue(array_devices[1]["name"] in valid_values)
        
        bluetooth.get_discovered_devices = get_discovered_devices_old
        
    def test_send_notification_via_bluetooth(self):   
        notification_type = NotificationType(name = "vaccination")
        notification_type.save()
        

# 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

            device_dict = {}
            device_dict[first_mac] = first_value
            device_dict[second_mac] = second_value
            return device_dict
        bluetooth.get_discovered_devices = new_get_discovered_devices
        
        response = self.client.post("/web/get_devices/")
        self.failUnlessEqual(response.status_code, 200)
        self.assertEquals(response["Content-Type"], "application/json")
        
        dict = json.loads(response.content)
        self.assertTrue(dict.has_key("devices"))
        array_devices = dict["devices"]
        
        self.assertEquals(len(array_devices), 2)
        self.assertTrue(array_devices[0].has_key("mac"))
        self.assertTrue(array_devices[0].has_key("name"))
        self.assertTrue(array_devices[0]["mac"] in valid_macs)
        self.assertTrue(array_devices[0]["name"] in valid_values)
        self.assertTrue(array_devices[1].has_key("mac"))
        self.assertTrue(array_devices[1].has_key("name"))
        self.assertTrue(array_devices[1]["mac"] in valid_macs)
        self.assertTrue(array_devices[1]["name"] in valid_values)
        
        bluetooth.get_discovered_devices = get_discovered_devices_old
        
    def test_send_notification_via_bluetooth(self):   
        notification_type = NotificationType(name = "vaccination")
        notification_type.save()
        

        notification_type = NotificationType.objects.get(pk=1)