def test_can_I_call_the_endorse_method(): from pbs.sites import PrescriptionSite site = PrescriptionSite() rf = RequestFactory() url = reverse('admin:endorse_authorise_summary') request = rf.get(url) response = site.endorse_authorise_summary(request) eq_(response.status_code, 200)
class testView: def setUp(self): from pbs.sites import PrescriptionSite self.site = PrescriptionSite() self.rf = RequestFactory() self.url = reverse("admin:endorse_authorise_summary") self.client = Client() self.client.login(username=os.environ["USERNAME"], password=os.environ["PASSWORD"]) def test_base_url(self): req = self.rf.get(self.url) res = self.site.endorse_authorise_summary(req) eq_(res.status_code, 200) def test_document_base_url(self): # url = ("/document/document/add/prescription/642/?tag=167&next=" + # "/implementation/burningprescription/prescription/642/") url = reverse("admin:document_document_add", args=["642"]) r = self.client.get(url)
class testView(): def setUp(self): from pbs.sites import PrescriptionSite self.site = PrescriptionSite() self.rf = RequestFactory() # e.g. url = ("/document/document/add/prescription/642/?tag=167&next=" + # "/implementation/burningprescription/prescription/642/") self.url = reverse('admin:document_document_add', args=['642']) self.client = Client() self.client.login(username=os.environ['USERNAME'], password=os.environ['PASSWORD']) self.add_season() self.add_region() self.add_ def add_season(self): s = Season() s.save() def add_region(self, name="test"): r = Region() r.name = name r.save() def test_we_can_add_a_region(self): qs = Region.objects.all() assert qs.count() == 0 name = "foo" self.add_region("foo") r = Region.objects.get(name=name) eq_(r.name, name) def test_base_url(self): req = self.rf.get(self.url) res = self.site.endorse_authorise_summary(req) eq_(res.status_code, 200) def xtest_document_base_url(self): print(os.environ['USERNAME']) url = reverse('admin:document_document_add', args=['642']) print("url is ", url) r = self.client.get(url) eq_(r.status_code, 200) def xtest_we_have_the_right_page(self): r = self.client.get(self.url) soup = BeautifulSoup(r.content) req_text = "Add Fire Behaviour Calculation document" h1_tags = soup.find_all('h1') print(h1_tags) assert False assert any(tag.string == req_text for tag in soup.findall('h1')) def test_no_bad_descriptor_on_get(self): url = reverse('admin:document_document_add', args=['642']) r = self.client.get(url) soup = BeautifulSoup(r.content) labels = soup.find_all('label') for lab in labels: print(lab.string) is_document_label = lambda t: t.text.startswith("Doc") bad_labels = filter(is_document_label, labels) assert not any(bad_labels) def test_empty_post_returns_bad_descriptor(self): pass
class testView(): def setUp(self): from pbs.sites import PrescriptionSite self.site = PrescriptionSite() self.rf = RequestFactory() # e.g. url = ("/document/document/add/prescription/642/?tag=167&next=" + # "/implementation/burningprescription/prescription/642/") self.url = reverse('admin:document_document_add', args= ['642']) self.client = Client() self.client.login(username=os.environ['USERNAME'], password=os.environ['PASSWORD']) self.add_season() self.add_region() self.add_ def add_season(self): s = Season() s.save() def add_region(self, name="test"): r = Region() r.name = name r.save() def test_we_can_add_a_region(self): qs = Region.objects.all() assert qs.count() == 0 name = "foo" self.add_region("foo") r = Region.objects.get(name=name) eq_(r.name, name) def test_base_url(self): req = self.rf.get(self.url) res = self.site.endorse_authorise_summary(req) eq_(res.status_code, 200) def xtest_document_base_url(self): print(os.environ['USERNAME']) url = reverse('admin:document_document_add', args= ['642']) print("url is ", url) r = self.client.get(url) eq_(r.status_code, 200) def xtest_we_have_the_right_page(self): r = self.client.get(self.url) soup = BeautifulSoup(r.content) req_text = "Add Fire Behaviour Calculation document" h1_tags = soup.find_all('h1') print(h1_tags) assert False assert any(tag.string == req_text for tag in soup.findall('h1')) def test_no_bad_descriptor_on_get(self): url = reverse('admin:document_document_add', args= ['642']) r = self.client.get(url) soup = BeautifulSoup(r.content) labels = soup.find_all('label') for lab in labels: print(lab.string) is_document_label = lambda t: t.text.startswith("Doc") bad_labels = filter(is_document_label, labels) assert not any(bad_labels) def test_empty_post_returns_bad_descriptor(self): pass
class testView(): def setUp(self): from pbs.sites import PrescriptionSite self.site = PrescriptionSite() self.rf = RequestFactory() self.url = reverse('admin:endorse_authorise_summary') self.client = Client() self.client.login(username=os.environ['USERNAME'], password=os.environ['PASSWORD']) def test_base_url(self): req = self.rf.get(self.url) res = self.site.endorse_authorise_summary(req) eq_(res.status_code, 200) def test_report_summary_url(self): url = self.url + "?report=summary" req = self.rf.get(url) eq_(req.GET['report'], 'summary') res = self.site.endorse_authorise_summary(req) eq_(res.status_code, 200) def test_client_can_login(self): assert self.client.login(username=os.environ['USERNAME'], password=os.environ['PASSWORD']) def test_report_approvals_has_dates(self): url = self.url + "?report=approvals" req = self.rf.get(url) data = { 'toDate': None, 'fromDate': None } response = self.client.post(url, data=data) form = response.context['form'] assert form.is_valid() eq_(response.context['title'], 'Approvals summary') eq_(form.cleaned_data.get('toDate'), date.today()) def test_report_ignitions_has_dates(self): url = self.url + "?report=ignitions" req = self.rf.get(url) data = { 'toDate': None, 'fromDate': None } response = self.client.post(url, data=data) form = response.context['form'] assert form.is_valid() eq_(response.context['title'], 'Ignitions summary') eq_(form.cleaned_data.get('toDate'), date.today()) def test_one_active_tab_summary(self): url = self.url + "?report=summary" response = self.client.get(url) soup = BeautifulSoup(response.content) report_tabs = soup.find("ul", {'id': 'report-tabs'}) active_tabs = report_tabs.find_all("li", {'class': 'active' }) eq_(len(active_tabs), 1) summary_tab = report_tabs.find_all("li", {'id': 'summary-tab', 'class': 'active' }) assert summary_tab def test_one_active_tab_approvals(self): url = self.url + "?report=approvals" response = self.client.get(url) soup = BeautifulSoup(response.content) report_tabs = soup.find("ul", {'id': 'report-tabs'}) active_tabs = report_tabs.find_all("li", {'class': 'active'}) eq_(len(active_tabs), 1) approvals_tab = report_tabs.find_all("li", {'id': 'approvals-tab', 'class': 'active' }) assert approvals_tab def test_one_active_tab_ignitions(self): url = self.url + "?report=ignitions" response = self.client.get(url) soup = BeautifulSoup(response.content) report_tabs = soup.find("ul", {'id': 'report-tabs'}) active_tabs = report_tabs.find_all("li", {'class': 'active'}) eq_(len(active_tabs), 1) ignitions_tab = report_tabs.find_all("li", {'id': 'ignitions-tab', 'class': 'active' }) assert ignitions_tab