Ejemplo n.º 1
0
 def test_lowercased(self):
     request = "AbCd"
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": request})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.key().name(), request.lower())
Ejemplo n.º 2
0
 def test_blank(self):
     # The title, if blank, should default to the slug.
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd", "title": ""})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.title, fetched.key().name())
Ejemplo n.º 3
0
 def test_blank(self):
     # The title, if blank, should default to the slug.
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd", "title": ""})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.title, fetched.key().name())
Ejemplo n.º 4
0
 def test_multiline(self):
     user = self.login()
     app = TestApp(application)
     description = "Election Description goes Here.\nMore lines are explicitly allowed."
     response = app.post("/create", params={"slug": "abcd", "description": description})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, description)
Ejemplo n.º 5
0
 def test_trimmed(self):
     user = self.login()
     app = TestApp(application)
     description = " Election Description goes Here\n"
     response = app.post("/create", params={"slug": "abcd", "description": description})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, description.strip())
Ejemplo n.º 6
0
 def test_explicit(self):
     # An empty string for the public attribute is interpreted as false.
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd", "public": ""})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.public, False)
Ejemplo n.º 7
0
 def test_explicit(self):
     user = self.login()
     app = TestApp(application)
     when = datetime(*(datetime.now() + timedelta(days=4, seconds=42)).timetuple()[:6])
     response = app.post("/create", params={"slug": "abcd", "closes": str(when)})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.closes, when)
Ejemplo n.º 8
0
 def test_omitted(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create",
                         params={"title": "Yet Another Design Competition"})
     fetched = Election.all().fetch(2)
     self.assertEqual(len(fetched), 0)
Ejemplo n.º 9
0
 def test_explicit(self):
     # An empty string for the public attribute is interpreted as false.
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd", "public": ""})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.public, False)
Ejemplo n.º 10
0
 def test_trimmed(self):
     user = self.login()
     app = TestApp(application)
     title = " Election Title goes Here\n"
     response = app.post("/create", params={"slug": "abcd", "title": title})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.title, title.strip())
Ejemplo n.º 11
0
 def test_lowercased(self):
     request = "AbCd"
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": request})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.key().name(), request.lower())
Ejemplo n.º 12
0
 def test_trimmed(self):
     user = self.login()
     app = TestApp(application)
     title = " Election Title goes Here\n"
     response = app.post("/create", params={"slug": "abcd", "title": title})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.title, title.strip())
Ejemplo n.º 13
0
 def test_blank(self):
     # The description, if blank, should default to the slug.
     user = self.login()
     app = TestApp(application)
     default = "Created by " + user.nickname()
     response = app.post("/create", params={"slug": "abcd", "description": ""})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, default)
Ejemplo n.º 14
0
 def test_default(self):
     # The description has something resembling a reasonable default.
     user = self.login()
     app = TestApp(application)
     default = "Created by " + user.nickname()
     response = app.post("/create", params={"slug": "abcd"})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, default)
Ejemplo n.º 15
0
 def test_creation_ignored(self):
     # The save routine should ignore a submitted created parameter.
     user = self.login()
     now = datetime.now()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd", "created": now + timedelta(days=2)})
     fetched = Election.all().fetch(1)[0]
     self.assertAlmostEqual(fetched.created, datetime.now(), delta=timedelta(seconds=2))
Ejemplo n.º 16
0
 def test_numbers(self):
     # Periods should be allowed, particularly in numbers.
     request = "something-1.3"
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": request})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.key().name(), request)
Ejemplo n.º 17
0
 def test_trimmed(self):
     # Spaces and hyphens should be trimmed from the ends of the slug.
     request = "-inner: "
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": request})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.key().name(), "inner")
Ejemplo n.º 18
0
 def test_punctuation(self):
     # The slug should replace punctuation with hyphens.
     request = "one and two, three/four; five"
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": request})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.key().name(), "one-and-two-three-four-five")
Ejemplo n.º 19
0
 def test_default(self):
     # The description has something resembling a reasonable default.
     user = self.login()
     app = TestApp(application)
     default = "Created by " + user.nickname()
     response = app.post("/create", params={"slug": "abcd"})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, default)
Ejemplo n.º 20
0
 def test_conflict(self):
     slug = "abcd"
     Election(key_name=slug).put()
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": slug})
     fetched = Election.all().fetch(2)
     self.assertEqual(len(fetched), 1)
Ejemplo n.º 21
0
 def test_conflict(self):
     slug = "abcd"
     Election(key_name=slug).put()
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": slug})
     fetched = Election.all().fetch(2)
     self.assertEqual(len(fetched), 1)
Ejemplo n.º 22
0
 def test_trimmed(self):
     # Spaces and hyphens should be trimmed from the ends of the slug.
     request = "-inner: "
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": request})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.key().name(), "inner")
Ejemplo n.º 23
0
 def test_numbers(self):
     # Periods should be allowed, particularly in numbers.
     request = "something-1.3"
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": request})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.key().name(), request)
Ejemplo n.º 24
0
 def test_added(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd"})
     fetched = Election.all().fetch(1)[0]
     self.assertAlmostEqual(fetched.starts,
                            datetime.now(),
                            delta=timedelta(seconds=2))
Ejemplo n.º 25
0
 def test_punctuation(self):
     # The slug should replace punctuation with hyphens.
     request = "one and two, three/four; five"
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": request})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.key().name(), "one-and-two-three-four-five")
Ejemplo n.º 26
0
 def test_user_ignored(self):
     # The save routine should ignore a submitted user parameter.
     user = self.login()
     email = "*****@*****.**"
     other = User(email=email)
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd", "user": email})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.creator, user)
Ejemplo n.º 27
0
 def test_user_ignored(self):
     # The save routine should ignore a submitted user parameter.
     user = self.login()
     email = "*****@*****.**"
     other = User(email=email)
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd", "user": email})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.creator, user)
Ejemplo n.º 28
0
 def test_form(self):
     # The creation form should fill in the slug properly.
     user = self.login()
     app = TestApp(application)
     page = app.get("/create")
     slug = "abcd"
     page.form.set("slug", slug)
     response = page.form.submit()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.key().name(), slug)
Ejemplo n.º 29
0
 def test_form(self):
     # The creation form should fill in the slug properly.
     user = self.login()
     app = TestApp(application)
     page = app.get("/create")
     slug = "abcd"
     page.form.set("slug", slug)
     response = page.form.submit()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.key().name(), slug)
Ejemplo n.º 30
0
 def test_form(self):
     # The creation form should fill in the title properly.
     user = self.login()
     app = TestApp(application)
     page = app.get("/create")
     title = "Election Title goes Here"
     page.form.set("slug", "abcd")
     page.form.set("title", title)
     response = page.form.submit()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.title, title)
Ejemplo n.º 31
0
 def test_form(self):
     # The creation form should fill in the title properly.
     user = self.login()
     app = TestApp(application)
     page = app.get("/create")
     title = "Election Title goes Here"
     page.form.set("slug", "abcd")
     page.form.set("title", title)
     response = page.form.submit()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.title, title)
Ejemplo n.º 32
0
 def test_trimmed(self):
     user = self.login()
     app = TestApp(application)
     description = " Election Description goes Here\n"
     response = app.post("/create",
                         params={
                             "slug": "abcd",
                             "description": description
                         })
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, description.strip())
Ejemplo n.º 33
0
 def test_form(self):
     # The creation form should fill in the description properly.
     user = self.login()
     app = TestApp(application)
     page = app.get("/create")
     description = "Election Description goes Here"
     page.form.set("slug", "abcd")
     page.form.set("description", description)
     response = page.form.submit()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, description)
Ejemplo n.º 34
0
 def test_multiline(self):
     user = self.login()
     app = TestApp(application)
     description = "Election Description goes Here.\nMore lines are explicitly allowed."
     response = app.post("/create",
                         params={
                             "slug": "abcd",
                             "description": description
                         })
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, description)
Ejemplo n.º 35
0
 def test_form(self):
     # The creation form should fill in the description properly.
     user = self.login()
     app = TestApp(application)
     page = app.get("/create")
     description = "Election Description goes Here"
     page.form.set("slug", "abcd")
     page.form.set("description", description)
     response = page.form.submit()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, description)
Ejemplo n.º 36
0
 def test_form(self):
     # The creation form should have a checkbox for the public property.
     # However, it shouldn't set the approved property.
     user = self.login()
     app = TestApp(application)
     page = app.get("/create")
     page.form.set("slug", "abcd")
     page.form.set("public", "1")
     response = page.form.submit()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.public, True)
     self.assertEquals(fetched.approved, False)
Ejemplo n.º 37
0
 def test_explicit(self):
     user = self.login()
     app = TestApp(application)
     when = datetime(*(datetime.now() +
                       timedelta(days=4, seconds=42)).timetuple()[:6])
     response = app.post("/create",
                         params={
                             "slug": "abcd",
                             "closes": str(when)
                         })
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.closes, when)
Ejemplo n.º 38
0
 def test_blank(self):
     # The description, if blank, should default to the slug.
     user = self.login()
     app = TestApp(application)
     default = "Created by " + user.nickname()
     response = app.post("/create",
                         params={
                             "slug": "abcd",
                             "description": ""
                         })
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.description, default)
Ejemplo n.º 39
0
 def test_form(self):
     # The creation form should have a checkbox for the public property.
     # However, it shouldn't set the approved property.
     user = self.login()
     app = TestApp(application)
     page = app.get("/create")
     page.form.set("slug", "abcd")
     page.form.set("public", "1")
     response = page.form.submit()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.public, True)
     self.assertEquals(fetched.approved, False)
Ejemplo n.º 40
0
 def test_creation_ignored(self):
     # The save routine should ignore a submitted created parameter.
     user = self.login()
     now = datetime.now()
     app = TestApp(application)
     response = app.post("/create",
                         params={
                             "slug": "abcd",
                             "created": now + timedelta(days=2)
                         })
     fetched = Election.all().fetch(1)[0]
     self.assertAlmostEqual(fetched.created,
                            datetime.now(),
                            delta=timedelta(seconds=2))
Ejemplo n.º 41
0
 def test_model(self):
     user = User(email="*****@*****.**")
     Election(creator = user).put()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.creator, user)
Ejemplo n.º 42
0
 def test_added(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd"})
     fetched = Election.all().fetch(1)[0]
     self.assertAlmostEqual(fetched.starts, datetime.now(), delta=timedelta(seconds=2))
Ejemplo n.º 43
0
 def test_checked(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd", "public": "1"})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.public, True)
Ejemplo n.º 44
0
 def test_added(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd"})
     fetched = Election.all().fetch(1)[0]
     self.assertGreater(fetched.closes, datetime.now() + timedelta(days=7))
Ejemplo n.º 45
0
 def test_user_added(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd"})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.creator, user)
Ejemplo n.º 46
0
 def test_omitted(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"title": "Yet Another Design Competition"})
     fetched = Election.all().fetch(2)
     self.assertEqual(len(fetched), 0)
Ejemplo n.º 47
0
 def test_empty(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": ""})
     fetched = Election.all().fetch(2)
     self.assertEqual(len(fetched), 0)
Ejemplo n.º 48
0
 def test_checked(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd", "public": "1"})
     fetched = Election.all().fetch(1)[0]
     self.assertEqual(fetched.public, True)
Ejemplo n.º 49
0
 def test_added(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd"})
     fetched = Election.all().fetch(1)[0]
     self.assertGreater(fetched.closes, datetime.now() + timedelta(days=7))
Ejemplo n.º 50
0
 def test_model(self):
     user = User(email="*****@*****.**")
     Election(creator=user).put()
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.creator, user)
Ejemplo n.º 51
0
 def test_user_added(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": "abcd"})
     fetched = Election.all().fetch(1)[0]
     self.assertEquals(fetched.creator, user)
Ejemplo n.º 52
0
 def test_empty(self):
     user = self.login()
     app = TestApp(application)
     response = app.post("/create", params={"slug": ""})
     fetched = Election.all().fetch(2)
     self.assertEqual(len(fetched), 0)