예제 #1
0
 def test_save_pack(self):
     pack = testpack.create_testpack(self.tlqs, self.tlcqs)
     fp = io.StringIO()
     testpack.save_testpack(pack, fp)
     fp.seek(0)
     # check the accented character in test list 1 name was written
     assert "\\u00e9" in fp.read()
예제 #2
0
 def test_extra_tests(self):
     extra = utils.create_test("extra test")
     extra_qs = models.Test.objects.filter(pk=extra.pk)
     pack = testpack.create_testpack(self.tlqs,
                                     self.tlcqs,
                                     extra_tests=extra_qs)
     fp = io.StringIO()
     testpack.save_testpack(pack, fp)
     fp.seek(0)
     assert "extra test" in fp.read()
예제 #3
0
 def test_non_destructive_load(self):
     ntl = models.TestList.objects.count()
     nt = models.Test.objects.count()
     pack = testpack.create_testpack(self.tlqs, self.tlcqs, self.extra)
     fp = io.StringIO()
     testpack.save_testpack(pack, fp)
     fp.seek(0)
     testpack.load_testpack(fp)
     assert models.TestList.objects.count() == 2 * ntl
     assert models.Test.objects.count() == 2 * nt
예제 #4
0
    def test_existing_created_user_not_overwritten(self):
        user2 = utils.create_user(uname="user2")
        pack = testpack.create_testpack(self.tlqs, self.tlcqs)

        fp = io.StringIO()
        testpack.save_testpack(pack, fp)
        fp.seek(0)
        testpack.load_testpack(fp, user2)

        assert models.TestList.objects.get(
            slug=self.tl1.slug).created_by != user2
예제 #5
0
 def test_extra_tests_loaded(self):
     extra = utils.create_test("extra test")
     extra_qs = models.Test.objects.filter(pk=extra.pk)
     pack = testpack.create_testpack(self.tlqs,
                                     self.tlcqs,
                                     extra_tests=extra_qs)
     fp = io.StringIO()
     testpack.save_testpack(pack, fp)
     fp.seek(0)
     models.Test.objects.all().delete()
     testpack.load_testpack(fp,
                            test_keys=[extra.natural_key()],
                            test_list_keys=[],
                            cycle_keys=[])
     assert models.Test.objects.filter(name=extra.name).exists()
예제 #6
0
    def test_load(self):
        pack = testpack.create_testpack(self.tlqs, self.tlcqs)
        models.TestList.objects.all().delete()
        models.Test.objects.all().delete()
        models.TestListCycle.objects.all().delete()

        fp = io.StringIO()
        testpack.save_testpack(pack, fp)
        fp.seek(0)
        testpack.load_testpack(fp)

        assert models.TestList.objects.filter(name=self.tl1.name).exists()
        assert models.Test.objects.filter(name=self.t1.name).exists()
        assert models.TestListCycle.objects.filter(name=self.tlc.name).exists()
        assert self.tl1.name in models.TestListCycle.objects.values_list(
            "test_lists__name", flat=True)
예제 #7
0
    def test_existing_objs_not_deleted(self):
        pack = testpack.create_testpack(self.tlqs, self.tlcqs)

        fp = io.StringIO()
        testpack.save_testpack(pack, fp)
        fp.seek(0)
        testpack.load_testpack(
            fp,
            test_keys=[self.t1.natural_key()],
            test_list_keys=[self.tl1.natural_key()],
            cycle_keys=[],
        )

        assert models.TestList.objects.filter(
            name__in=[self.tl2.name, self.tl3.name]).count() == 2
        assert models.Test.objects.filter(
            name__in=[self.t2.name, self.t3.name]).count() == 2
        assert models.TestListCycle.objects.filter(
            name__in=[self.tlc.name]).count() == 1
예제 #8
0
    def test_selective_load(self):
        pack = testpack.create_testpack(models.TestList.objects.all(),
                                        self.tlcqs)
        models.TestList.objects.all().delete()
        models.Test.objects.all().delete()
        models.TestListCycle.objects.all().delete()

        fp = io.StringIO()
        testpack.save_testpack(pack, fp)
        fp.seek(0)
        testpack.load_testpack(
            fp,
            test_keys=[self.t1.natural_key()],
            test_list_keys=[self.tl1.natural_key()],
            cycle_keys=[],
        )

        assert models.TestList.objects.count() == 1
        assert models.Test.objects.count() == 1
        assert models.TestListCycle.objects.count() == 0