class DenormalizedTrailTest(AuthentFixturesTest): def setUp(self): self.trail1 = TrailFactory(no_path=True) self.trail2 = TrailFactory(no_path=True) self.path = PathFactory() self.trail1.add_path(self.path) self.trail2.add_path(self.path) def test_path_and_trails_are_linked(self): self.assertIn(self.trail1, self.path.trails.all()) self.assertIn(self.trail2, self.path.trails.all()) def login(self): user = PathManagerFactory(password='******') success = self.client.login(username=user.username, password='******') self.assertTrue(success) def test_denormalized_path_trails(self): PathFactory.create_batch(size=50) TrailFactory.create_batch(size=50) self.login() with self.assertNumQueries(LTE(15)): self.client.get(reverse('core:path_json_list')) def test_trails_are_shown_as_links_in_list(self): self.login() response = self.client.get(reverse('core:path_json_list')) self.assertEqual(response.status_code, 200) paths_json = json.loads(response.content) trails_column = paths_json['aaData'][0][4] self.assertTrue(trails_column == u'%s, %s' % (self.trail1.name_display, self.trail2.name_display) or trails_column == u'%s, %s' % (self.trail2.name_display, self.trail1.name_display))
class DenormalizedTrailTest(AuthentFixturesTest): def setUp(self): self.trail1 = TrailFactory(no_path=True) self.trail2 = TrailFactory(no_path=True) self.path = PathFactory() self.trail1.add_path(self.path) self.trail2.add_path(self.path) def test_path_and_trails_are_linked(self): self.assertIn(self.trail1, self.path.trails.all()) self.assertIn(self.trail2, self.path.trails.all()) def login(self): user = PathManagerFactory(password='******') success = self.client.login(username=user.username, password='******') self.assertTrue(success) def test_denormalized_path_trails(self): PathFactory.create_batch(size=50) TrailFactory.create_batch(size=50) self.login() with self.assertNumQueries(LTE(15)): self.client.get(reverse('core:path_json_list')) def test_trails_are_shown_as_links_in_list(self): self.login() response = self.client.get(reverse('core:path_json_list')) self.assertEqual(response.status_code, 200) paths_json = json.loads(response.content) trails_column = paths_json['aaData'][0][4] self.assertTrue(trails_column == u'%s, %s' % (self.trail1.name_display, self.trail2.name_display) or trails_column == u'%s, %s' % (self.trail2.name_display, self.trail1.name_display))
class DenormalizedTrailTest(AuthentFixturesTest): def setUp(self): self.trail1 = TrailFactory(no_path=True) self.trail2 = TrailFactory(no_path=True) self.path = PathFactory() self.trail1.add_path(self.path) self.trail2.add_path(self.path) def test_path_and_trails_are_linked(self): self.assertIn(self.trail1, self.path.trails.all()) self.assertIn(self.trail2, self.path.trails.all()) def login(self): user = PathManagerFactory(password='******') success = self.client.login(username=user.username, password='******') self.assertTrue(success) def test_denormalized_path_trails(self): PathFactory.create_batch(size=50) TrailFactory.create_batch(size=50) self.login() with self.assertNumQueries(LTE(15)): self.client.get(reverse('core:path_json_list'))
class DenormalizedTrailTest(AuthentFixturesTest): def setUp(self): self.trail1 = TrailFactory(no_path=True) self.trail2 = TrailFactory(no_path=True) self.path = PathFactory() self.trail1.add_path(self.path) self.trail2.add_path(self.path) def test_path_and_trails_are_linked(self): self.assertIn(self.trail1, self.path.trails.all()) self.assertIn(self.trail2, self.path.trails.all()) def login(self): user = PathManagerFactory(password='******') success = self.client.login(username=user.username, password='******') self.assertTrue(success) def test_denormalized_path_trails(self): PathFactory.create_batch(size=50) TrailFactory.create_batch(size=50) self.login() with self.assertNumQueries(LTE(15)): self.client.get(reverse('core:path_json_list'))