Exemple #1
0
def create_host(id):
    client_ip = id.replace('.','')
    if User.objects.filter(ip_address=client_ip).exists():

        user = User.objects.get(ip_address=client_ip)
        user.songs_added = 0
        user.status = "H"
        user.save()

    else:
        user = User(ip_address = client_ip,songs_added = 0, status = 'H')
        user.save()

    return user
Exemple #2
0
 def test_status(self):
     u = User(ip_address = 100,songs_added = 10000, status = "OK")
     self.assertRaises(ValueError,u.save())
Exemple #3
0
 def test_ip(self):
     u = User(ip_address = -100,songs_added = 0)
     self.assertRaises(ValueError,u.save())