def test_authenticating_users(self): """Tests the authentication of users""" # Creates the users user1 = FomoUser() user1.first_name = 'Stephane' user1.last_name = 'Akoki' user1.set_password('baseball') user1.date_joined = datetime.now() user1.last_login = datetime.now() user1.username = '******' user1.email = '*****@*****.**' user1.phone = '336-486-4595' user1.address = '1960 N Canyon Rd' user1.city = 'Provo' user1.state = 'Utah' user1.zip_code = '84604' user1.is_superuser = True user1.is_staff = True user1.is_active = True user1.save() #pull back off of the database user1auth = authenticate(username=user1.username, password='******') u2 = FomoUser.objects.get(username='******') self.assertEqual(u2, user1auth)
for p in Permission.objects.all(): # print(p.code) g3.permissions.add(p) g3.permissions.add(Permission.objects.get(codename=('View_products'))) g3.permissions.add(Permission.objects.get(codename=('View_users'))) g3.permissions.add(Permission.objects.get(codename=('change_fomouser'))) #Query all / some with different query OPTIONS # 3 - 5 examples u1 = FomoUser() u1.first_name = "Stephane" u1.last_name = "Akoki" u1.username = "******" u1.set_password("jeuvideo") u1.address = "Provo" u1.zip = '84604' u1.date_joined = datetime.now() u1.last_login = datetime.now() u1.email = "*****@*****.**" u1.phone_number = "8013863392" u1.city = "Provo" u1.state = "UT" u1.is_staff = True u1.is_active = True u1.save() u2 = FomoUser() u2.first_name = "Xavier" u2.last_name = "Akoki" u2.username = "******"
import os #initialize django environement os.environ['DJANGO_SETTINGS_MODULE'] = 'fomo.settings' import django django.setup() from account.models import FomoUser #user 1 user1 = FomoUser() user1.address = "Provo, UT 84602" user1.city = "Provo" user1.gender = "Female" user1.phone = "801-422-4636" user1.state = "UTAH" user1.stateinitial = "UT" user1.zipcode = "84602" user1.save() #user 2 user2 = FomoUser() user2.address = "Provo, UT 84602" user2.city = "Provo" user2.gender = "Female" user2.phone = "801-422-4636" user2.state = "UTAH" user2.stateinitial = "UT" user2.zipcode = "84602" user2.save()