Example #1
0
class DeleteModelsTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.user = User.objects.create_superuser(
            username="******",
            password="******",
            email="*****@*****.**")
        self.client.force_login(self.user)
        self.composition = Composition(name='compo')
        self.composition.save(user=self.user)

        self.track = Track()
        self.track.save(user=self.user, composition_id=self.composition.id)

    def test_delete_composition(self):
        self.assertEqual(len(Composition.objects.all()), 1)
        response = self.client.get(reverse('delete_composition', kwargs={'composition_id': self.composition.id}))
        index_path = reverse('index')
        self.assertRedirects(response, index_path)
        response = self.client.get(index_path)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(Composition.objects.all()), 0)

    def test_delete_track(self):
        self.assertEqual(len(Track.objects.all()), 1)
        response = self.client.get(reverse('delete_track', kwargs={'track_id': self.track.id}))
        compo_path = reverse('show_composition', kwargs={'composition_id': self.composition.id})
        self.assertRedirects(response, compo_path)
        response = self.client.get(compo_path)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(Track.objects.all()), 0)
 def test_login_required_create_track(self):
     compo = Composition()
     user = User()
     user.save()
     compo.save(user=user)
     self.test_login_required(view_name='create_track',
                              kwargs={'composition_id': compo.id})
Example #3
0
 def setUp(self):
     self.client = Client()
     self.user = User.objects.create_superuser(username="******",
                                               password="******",
                                               email="*****@*****.**")
     self.client.force_login(self.user)
     self.composition = Composition(name='compo')
     self.composition.save(user=self.user)
     self.composition2 = Composition(name='name')
     self.composition2.save(user=self.user)
Example #4
0
def update_champion_compositions(champion, compositions):
    for composition in compositions:
        compositionobject = None
        try:
            compositionobject = Composition.objects.get(name=composition["name"])
        except ObjectDoesNotExist:
            compositionobject = Composition(name=composition["name"])
            compositionobject.save()
            compcounterlist = CompositionCounterList(composition=compositionobject)
            compcounterlist.save()
        championroleobject = ChampionRole(composition=compositionobject, champion=champion, description=composition["description"])
        championroleobject.save()
 def test_create_variation_post(self):
     compo = Composition()
     compo.save(user=self.user)
     track = Track()
     track.save(user=self.user, composition_id=compo.id)
     show_variation_path = reverse('show_variation',
                                   kwargs={'variation_id': 1})
     response = self.client.post(
         reverse('create_variation', kwargs={'composition_id': compo.id}), {
             'name': 'vari1',
             'tracks': [str(track.id)]
         })
     self.assertRedirects(response, show_variation_path)
     response = self.client.get(show_variation_path)
     self.assertEqual(response.status_code, 200)
class EditVariationTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.user = User.objects.create_superuser(
            username="******",
            password="******",
            email="*****@*****.**")
        self.client.force_login(self.user)
        self.composition = Composition(name='compo')
        self.composition.save(user=self.user)
        self.variation = Variation(name='my_variation')
        self.variation.save(user=self.user, composition_id=self.composition.id)

    def test_edit_variation_get(self):
        response = self.client.get(reverse('edit_variation', kwargs={'variation_id': self.variation.id}))
        self.assertEqual(response.status_code, 200)
 def setUpTestData(cls):
     cls.client = Client()
     cls.user = User.objects.create_superuser(username="******",
                                              password="******",
                                              email="*****@*****.**")
     cls.client.force_login(cls.user)
     cls.composition = Composition(name='compo')
     cls.composition.save(user=cls.user)
class ForkVariationTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.user = User.objects.create_superuser(username="******",
                                                  password="******",
                                                  email="*****@*****.**")
        self.client.force_login(self.user)
        self.composition = Composition(name='compo')
        self.composition.save(user=self.user)
        self.variation = Variation(name='my_variation')
        self.variation.save(user=self.user, composition_id=self.composition.id)

    def test_fork_variation(self):
        self.assertEqual(len(Composition.objects.all()), 1)
        self.assertEqual(len(Variation.objects.all()), 1)
        response = self.client.get(
            reverse('fork_variation',
                    kwargs={'variation_id': self.variation.id}))
        self.assertEqual(len(Variation.objects.all()), 2)
Example #9
0
class SearchCompositionsTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.user = User.objects.create_superuser(username="******",
                                                  password="******",
                                                  email="*****@*****.**")
        self.client.force_login(self.user)
        self.composition = Composition(name='compo')
        self.composition.save(user=self.user)
        self.composition2 = Composition(name='name')
        self.composition2.save(user=self.user)

    def test_search_compositions(self):
        self.assertEqual(Composition.objects.count(), 2)
        response = self.client.get(reverse('search_compositions'),
                                   data={'phrase': 'compo'})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['compositions']), 1)
        self.assertEqual(response.context['compositions'][0].id,
                         self.composition.id)