예제 #1
0
	def test_geocache_and_log_relationship(self):
		g = Geocache()
		g.save()
		log = Log(id=None, text="test text", geocache=g)
		log.save()
		self.assertEqual(log.text, "test text")
		log2 = Log(id=None, text="test text", geocache=g)
		log2.save()
		saved_logs = Log.objects.all()
		self.assertEqual(saved_logs.count(), 2)
예제 #2
0
	def test_all_previous_logs_are_shown(self):
		g = Geocache()
		g.save()
		first_log = Log(id=None, text="Test for first log", geocache=g)
		first_log.save()
		second_log = Log(id=None, text="Test for second log", geocache=g)
		second_log.save()
		request = HttpRequest()
		
		response = listing(request, g.id)

		self.assertIn("Test for first log", response.content.decode())
		self.assertIn("Test for second log", response.content.decode())
예제 #3
0
	def test_saving_and_retrieving_difficulty(self):
		good_listing = Geocache()
		good_listing.difficulty = 3
		good_listing.save()

		bad_listing = Geocache()
		bad_listing.difficulty = 6
		bad_listing.save()

		saved_listings = Geocache.objects.all()
		self.assertEqual(saved_listings[0].difficulty, 3)
예제 #4
0
	def test_saving_and_retrieving_positive_and_negative_coordinates(self):
		first_listing = Geocache()
		first_listing.latitude = 10.000001
		first_listing.longitude = -10.000001
		first_listing.save()

		second_listing = Geocache()
		second_listing.latitude = 20.100000
		second_listing.longitude = -20.100000
		second_listing.save()

		saved_listings = Geocache.objects.all()
		self.assertEqual(saved_listings.count(), 2)

		first_saved_listing = saved_listings[0]
		second_saved_listing = saved_listings[1]
		self.assertEqual(first_saved_listing.latitude, 10.000001)
		self.assertEqual(first_saved_listing.longitude, -10.000001)
		self.assertEqual(second_saved_listing.latitude, 20.100000)
		self.assertEqual(second_saved_listing.longitude, -20.100000)
예제 #5
0
	def test_saving_and_retrieving_items(self):
		first_listing = Geocache()
		first_listing.title = "First Geocache Listing"
		first_listing.description = "First geocache description."
		first_listing.save()

		second_listing = Geocache()
		second_listing.title = "Second Geocache Listing"
		second_listing.description = "Second geocache description."
		second_listing.save()

		saved_listings = Geocache.objects.all()
		self.assertEqual(saved_listings.count(), 2)

		first_saved_listing = saved_listings[0]
		second_saved_listing = saved_listings[1]
		self.assertEqual(first_saved_listing.title, "First Geocache Listing")
		self.assertEqual(first_saved_listing.description, "First geocache description.")
		self.assertEqual(second_saved_listing.title, "Second Geocache Listing")
		self.assertEqual(second_saved_listing.description, "Second geocache description.")
예제 #6
0
	def test_saving_and_retrieving_hint(self):
		first_listing = Geocache()
		first_listing.hint = "Hint for cache"
		first_listing.save()

		second_listing = Geocache()
		second_listing.hint = "Hint for cache"
		second_listing.save()

		saved_listings = Geocache.objects.all()
		self.assertEqual(saved_listings.count(), 2)

		first_saved_listing = saved_listings[0]
		second_saved_listing = saved_listings[1]
		self.assertEqual(first_saved_listing.hint, "Hint for cache")
		self.assertEqual(second_saved_listing.hint, "Hint for cache")
예제 #7
0
	def setUp(self):

		# bit of a hack, prepopulating the database
		first_listing = Geocache(
			title="First Geocache Listing",
			description="Test description",
			latitude=00.000000,
			longitude=00.000000,
			)
		first_listing.save()
		second_listing = Geocache(title="Second Geocache Listing")
		second_listing.save()

		self.browser = webdriver.Firefox()
		self.browser.implicitly_wait(3)
예제 #8
0
	def test_can_covert_decimal_coordinates_to_DMS(self):
		g = Geocache(latitude=32.603020, longitude=96.863314)
		self.assertEqual(
			g.dms(), "N 32 36' 10.872\" W 96 51' 47.93\""
		)