def test_setting_password(monkeypatch): #Initialization user = User("taimoor","secretTaimoorPassword") #The password is not really secret assert user.getPassword() == "secretTaimoorPassword" #Checking for comparison between different passwords assert not user.getPassword() == "someOtherString" #Checking that internally automagically the # string case is not being ignored... assert not user.getPassword() == "secrettaimoorpassword"
def test_find_found_in_id_map_not_found_in_DB(monkeypatch): # Test Data expected = User('joel', 'shmoel', True) # Mock def id_find(_, __): return expected def no_find(_): return monkeypatch.setattr(IdMap, 'find', id_find) monkeypatch.setattr(UserTDG, 'find', no_find) # Execute val = UserMapper.find(1) # Verify assert (val.getPassword() is expected.getPassword()) assert (val.getId() is expected.getId()) assert (val.isCapstone() is expected.isCapstone())