def test_user_map(self): # Create some users with position for _ in range(10): UserFactory(lng=32.87109375, lat=55.7023550933) url = reverse('accounts:map') # test anonymous user response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertEqual(response.context['user_position_json'], 'null') other_positions = json.loads(response.context['other_positions_json']) self.assertEqual(len(other_positions), 10) # test authenticated user self.login() self.user.lat = 1 self.user.lng = 1 self.user.save() response = self.client.get(url) self.assertEqual(response.status_code, 200) user_position = json.loads(response.context['user_position_json']) self.assertEqual(user_position, self.user.get_position()) other_positions = json.loads(response.context['other_positions_json']) self.assertEqual(len(other_positions), 10)
def setUp(self): self.user = UserFactory(username='******', email='*****@*****.**', password='******')