def setUp(self): super(TestUser, self).setUp() self.store = FakeStore() with mock.patch("uuid.uuid4") as mock_uuid: mock_uuid.return_value.hex = "tokenvalue" self.user = User.use(self.store)( name="Foo Bar", email="*****@*****.**", password="******")
def test_index(self, driver): driver.get("/") driver.find_element_by_id("register-name").send_keys("Foo Bar") driver.find_element_by_id("register-email").send_keys( "*****@*****.**") driver.find_element_by_id("register-password").send_keys("foobar") driver.find_element_by_id("register-submit").click() user = User.use(self.store).store.fetch("*****@*****.**") self.assertIsNotNone(user, "New user should be in database.") self.assertEqual("*****@*****.**", user.email) self.assertEqual("Foo Bar", user.name) self.assertTrue(user.authenticate("foobar")) # should ultimately land on homepage self.assertTrue(driver.current_url.endswith( "/contests/{0}".format(config.CONTEST_ID)))
def test_user_save(self): self.user.store.save() user = User.use(self.store).store.fetch(self.user.id) self.assertEqual(user, self.user) self.assertEqual("tokenvalue", user.token)