def test_add_host_user_has_no_hosts(self): new_host = "testing.ug.eie.wits.ac.za" host_less = { "username": "******", "first_name": "Host", "last_name": "Less", "email": ["*****@*****.**"], "password": "******", "yos": "1" } expected = { 'username': '******', 'gid_number': '1000', 'login_shell': '/bin/bash', 'first_name': 'Host', 'last_name': 'Less', 'hosts': ['testing.ug.eie.wits.ac.za'], 'home_directory': '/home/ug/hostless', 'uid_number': '1000', 'yos': '1', 'email': ['*****@*****.**'] } users.delete(host_less['username']) users.add(host_less) users.add_host(host_less['username'], new_host) user = users.find_one(host_less['username']) self.assertEquals(user, expected)
def setUp(self): self.valid = { "username": "******", "first_name": "Gunea", "last_name": "Pig", "email": ["*****@*****.**"], "password": "******", "hosts": ['dummy'], "yos": "1" } self.existing_user = { "username": "******", "first_name": "John", "last_name": "Doe", "email": ["*****@*****.**"], "password": "******", "hosts": ['dummy'], "gid_number": "4000", "uid_number": "4001", "login_shell": "/bin/bash", "home_directory": "/home/ug/johnd", "yos": "4" } self.missing_attributes = { "username": "******", "password": "******", "hosts": ['dummy'], "yos": "4" } users.delete(self.existing_user['username']) users.add(self.existing_user)
def setUp(self): self.existing_user = {"username": "******", "first_name": "Jane", "last_name": "Doe", "email": ["*****@*****.**"], "password": "******", "hosts": ['dummy'], "gid_number": "4000", "uid_number": "4001", "login_shell": "/bin/bash", "home_directory": "/home/ug/janed", "yos": "4"} self.existing_user2 = {"username": "******", "first_name": "John", "last_name": "Doe", "email": ["*****@*****.**"], "password": "******", "hosts": ['dummy'], "gid_number": "4000", "uid_number": "4001", "login_shell": "/bin/bash", "home_directory": "/home/ug/johnd", "yos": "4"} users.delete(self.existing_user['username']) users.delete(self.existing_user2['username']) users.add(self.existing_user) users.add(self.existing_user2) self.valid = {"name": "natsuki", "gid_number": "1000", "description": "Natsuki, like the summer", "members": [self.existing_user['username']]} self.updated_valid = {"name": "natsuki", "gid_number": "1000", "description": "Natsuki, like the summer", "members": [self.existing_user['username'], self.existing_user2['username']]} self.no_members = {"name": "navina"} self.empty_members = {"name": "navina", "members": []}
def setUp(self): self.existing_user = {"username": "******", "first_name": "Gunea", "last_name": "Pig", "email": ["*****@*****.**"], "password": "******", "hosts": ['babbage.ug.eie.wits.ac.za'], "yos": "3"} self.existing_user2 = {"username": "******", "first_name": "John", "last_name": "Doe", "email": ["*****@*****.**"], "password": "******", "hosts": ['dummy'], "gid_number": "4000", "uid_number": "4001", "login_shell": "/bin/bash", "home_directory": "/home/ug/johnd", "yos": "4"} users.delete(self.existing_user['username']) users.delete(self.existing_user2['username']) users.add(self.existing_user) users.add(self.existing_user2) self.existing_group = {"name": "natsuki", "gid_number": "1000", "description": "Natsuki, like the summer", "members": [self.existing_user['username']]} groups.save(self.existing_group) self.non_existing_user = "******" groups.save(self.existing_group) self.new_member = {"username": "******", "first_name": "John", "last_name": "Doe", "email": ["*****@*****.**"], "password": "******", "hosts": ['dummy'], "yos": "4"}
def tearDown(self): users.delete(self.existing_user['username']) users.delete(self.existing_user2['username']) groups.delete(self.valid['name']) groups.delete(self.updated_valid['name'])
def tearDown(self): users.delete(self.existing_user['username']) users.delete(self.existing_user2['username']) groups.delete(self.existing_group['name'])
def test_delete_nothing_given(self): '''as long as this call does not fail''' self.assertFalse(users.delete())
def test_delete_no_username_given(self): '''as long as this call does not fail''' users.delete(user=self.existing_user)
def test_delete(self): '''simply delete a user, try to find it and see if its really gone''' users.delete(self.existing_user['username'])
def tearDown(self): users.delete(self.existing_user['username']) users.delete(self.valid['username'])