Ejemplo n.º 1
0
 def test_submit_xls(self, noop, save_mock):
     f = open(self.test_xls, 'r')
     req = req_factory_factory(self.submit_url, user=self.user, post=True,
                               data={'agree': True, 'test_plan': f})
     r = preload_submit(req, self.webapp.slug)
     self.assert3xx(r, self.url)
     self._assert_submit('xls', 'application/vnd.ms-excel', save_mock)
Ejemplo n.º 2
0
 def test_submit_xls(self, noop, save_mock):
     f = open(self.test_xls, 'r')
     req = req_factory_factory(self.submit_url, user=self.user, post=True,
                               data={'agree': True, 'test_plan': f})
     r = preload_submit(req, self.webapp.app_slug)
     self.assert3xx(r, self.url)
     self._assert_submit('xls', 'application/vnd.ms-excel', save_mock)
Ejemplo n.º 3
0
    def test_submit_multiple_status(self, noop, save_mock):
        f = open(self.test_xls, "r")
        req = req_factory_factory(self.submit_url, user=self.user, post=True, data={"test_plan": f, "agree": True})
        preload_submit(req, self.webapp.slug)
        self._submit_pdf()

        eq_(PreloadTestPlan.objects.count(), 2)
        xls = PreloadTestPlan.objects.get(filename__contains="xls")
        pdf = PreloadTestPlan.objects.get(filename__contains="pdf")
        eq_(xls.status, amo.STATUS_DISABLED)
        eq_(pdf.status, amo.STATUS_PUBLIC)

        # Check the link points to most recent one.
        req = req_factory_factory(self.url, user=self.user)
        r = status(req, self.webapp.slug)
        doc = pq(r.content)
        eq_(doc(".test-plan-download").attr("href"), pdf.preload_test_plan_url)
Ejemplo n.º 4
0
    def test_submit_no_file(self, noop, save_mock):
        req = req_factory_factory(self.submit_url, user=self.user, post=True, data={"agree": True})
        r = preload_submit(req, self.webapp.slug)
        eq_(r.status_code, 200)
        eq_(PreloadTestPlan.objects.count(), 0)
        assert not save_mock.called

        assert "required" in pq(r.content)(".test_plan .errorlist").text()
Ejemplo n.º 5
0
    def test_submit_bad_file(self, noop, save_mock):
        f = open(os.path.abspath(__file__), "r")
        req = req_factory_factory(self.submit_url, user=self.user, post=True, data={"agree": True, "test_plan": f})
        r = preload_submit(req, self.webapp.slug)
        eq_(r.status_code, 200)
        eq_(PreloadTestPlan.objects.count(), 0)
        assert not save_mock.called

        assert "Invalid file type." in pq(r.content)(".test_plan .errorlist").text()
Ejemplo n.º 6
0
    def test_submit_no_file(self, noop, save_mock):
        req = req_factory_factory(self.submit_url, user=self.user, post=True,
                                  data={'agree': True})
        r = preload_submit(req, self.webapp.slug)
        eq_(r.status_code, 200)
        eq_(PreloadTestPlan.objects.count(), 0)
        assert not save_mock.called

        assert 'required' in pq(r.content)('.test_plan .errorlist').text()
Ejemplo n.º 7
0
    def test_submit_no_agree(self, noop, save_mock):
        f = open(self.test_xls, 'r')
        req = req_factory_factory(self.submit_url, user=self.user, post=True,
                                  data={'test_plan': f})
        r = preload_submit(req, self.webapp.app_slug)
        eq_(r.status_code, 200)
        eq_(PreloadTestPlan.objects.count(), 0)
        assert not save_mock.called

        assert 'required' in pq(r.content)('.agree .errorlist').text()
Ejemplo n.º 8
0
 def _submit_pdf(self):
     f = open(self.test_pdf, 'r')
     req = req_factory_factory(self.submit_url,
                               user=self.user,
                               post=True,
                               data={
                                   'agree': True,
                                   'test_plan': f
                               })
     return preload_submit(req, self.webapp.slug)
Ejemplo n.º 9
0
    def test_submit_multiple_status(self, noop, save_mock):
        f = open(self.test_xls, 'r')
        req = req_factory_factory(self.submit_url, user=self.user, post=True,
                                  data={'test_plan': f, 'agree': True})
        preload_submit(req, self.webapp.app_slug)
        self._submit_pdf()

        eq_(PreloadTestPlan.objects.count(), 2)
        xls = PreloadTestPlan.objects.get(filename__contains='xls')
        pdf = PreloadTestPlan.objects.get(filename__contains='pdf')
        eq_(xls.status, mkt.STATUS_DISABLED)
        eq_(pdf.status, mkt.STATUS_PUBLIC)

        # Check the link points to most recent one.
        req = req_factory_factory(self.url, user=self.user)
        r = status(req, self.webapp.app_slug)
        doc = pq(r.content)
        eq_(doc('.test-plan-download').attr('href').split('?')[0],
            pdf.preload_test_plan_url.split('?')[0])
Ejemplo n.º 10
0
    def test_submit_multiple_status(self, noop, save_mock):
        f = open(self.test_xls, 'r')
        req = req_factory_factory(self.submit_url, user=self.user, post=True,
                                  data={'test_plan': f, 'agree': True})
        preload_submit(req, self.webapp.slug)
        self._submit_pdf()

        eq_(PreloadTestPlan.objects.count(), 2)
        xls = PreloadTestPlan.objects.get(filename__contains='xls')
        pdf = PreloadTestPlan.objects.get(filename__contains='pdf')
        eq_(xls.status, amo.STATUS_DISABLED)
        eq_(pdf.status, amo.STATUS_PUBLIC)

        # Check the link points to most recent one.
        req = req_factory_factory(self.url, user=self.user)
        r = status(req, self.webapp.slug)
        doc = pq(r.content)
        eq_(doc('.test-plan-download').attr('href'),
            pdf.preload_test_plan_url)
Ejemplo n.º 11
0
    def test_submit_bad_file(self, noop, save_mock):
        f = open(os.path.abspath(__file__), 'r')
        req = req_factory_factory(self.submit_url, user=self.user, post=True,
                                  data={'agree': True, 'test_plan': f})
        r = preload_submit(req, self.webapp.app_slug)
        eq_(r.status_code, 200)
        eq_(PreloadTestPlan.objects.count(), 0)
        assert not save_mock.called

        assert ('Invalid file type' in
                pq(r.content)('.test_plan .errorlist').text())
Ejemplo n.º 12
0
    def test_submit_bad_file(self, noop, save_mock):
        f = open(os.path.abspath(__file__), 'r')
        req = req_factory_factory(self.submit_url, user=self.user, post=True,
                                  data={'agree': True, 'test_plan': f})
        r = preload_submit(req, self.webapp.slug)
        eq_(r.status_code, 200)
        eq_(PreloadTestPlan.objects.count(), 0)
        assert not save_mock.called

        assert ('Invalid file type.' in
                pq(r.content)('.test_plan .errorlist').text())
Ejemplo n.º 13
0
 def _submit_pdf(self):
     f = open(self.test_pdf, 'r')
     req = req_factory_factory(self.submit_url, user=self.user, post=True,
                               data={'agree': True, 'test_plan': f})
     return preload_submit(req, self.webapp.app_slug)
Ejemplo n.º 14
0
 def test_submit_xls(self, noop, save_mock):
     f = open(self.test_xls, "r")
     req = req_factory_factory(self.submit_url, user=self.user, post=True, data={"agree": True, "test_plan": f})
     r = preload_submit(req, self.webapp.slug)
     self.assert3xx(r, self.url)
     self._assert_submit("xls", "application/vnd.ms-excel", save_mock)
Ejemplo n.º 15
0
 def _submit_pdf(self):
     f = open(self.test_pdf, "r")
     req = req_factory_factory(self.submit_url, user=self.user, post=True, data={"agree": True, "test_plan": f})
     return preload_submit(req, self.webapp.slug)