How to use not_be method in Sure

Best Python code snippet using sure_python

tests.py

Source:tests.py Github

copy

Full Screen

1from nuremberg.core.tests.acceptance_helpers import *2from nuremberg.search.templatetags.search_url import url_with_query3from nuremberg.transcripts.models import Transcript, TranscriptPage4from django.core.management import call_command5from datetime import datetime6from os import path7@pytest.fixture8def seq():9 def get_seq(seq=1):10 transcript = Transcript.objects.get(id=1)11 return go_to(url_with_query('transcripts:show', transcript.id, transcript.slug(), seq=seq))12 return get_seq13def test_transcript_viewer(seq):14 page = seq(1)15 page('h1').text().should.contain('Transcript for NMT 1: Medical Case')16 page('p').text().should.contain('This is a corrected copy of transcript for 5 December 1946.')17def test_transcript_search(seq):18 page = go_to(url('transcripts:search', kwargs={'transcript_id':1}))19 search_bar = page('input[type="search"]')20 search_bar.should.not_be.empty21 search_bar.val().should.equal('*')22 page('mark').text().should.be.empty23 page('a').with_text('Page 26').should.not_be.empty24 page = go_to(search_bar.submit_value('exhibit'))25 search_bar = page('input[type="search"]')26 search_bar.should.not_be.empty27 search_bar.val().should.equal('exhibit')28 page.text().should.contain('2333 pages with results')29 page('mark').text().should.contain('exhibit')30 page_link = page('a').with_text('Page 88')31 page_link.should.not_be.empty32 page = follow_link(page_link)33 search_bar = page('input[type="search"]')34 search_bar.should.not_be.empty35 search_bar.val().should.equal('exhibit')36 page.text().should.contain('Page 88')37def test_transcript_joins(seq):38 page = seq(1)39 text = page.text()40 text.should.contain('HLSL Seq. No. 1')41 # There should be four page joins in the first ten pages:42 text.should.contain('purely speculative diffi culties.\nHLSL Seq. No. 5') # This page break moves to:43 text.should.contain('Wehrmacht, the Medical Service of the SS') # This page break moves to:44 text.should.contain('and so forth.\nHLSL Seq. No. 7')45 text.should.contain('have to look through each individual document') # This page break moves to:46 text.should.contain('carry this out in practice.\nHLSL Seq. No. 9')47 text.should.contain(' probably very relevant and important ones.\nHLSL Seq. No. 10')48 # it should contain each page number once49 handles = page('.page-handle')50 handles.length.should.equal(10)51 print(handles.outerHtml())52 print([handles.text()])53 handles.with_text('HLSL SEQ. NO. 1 ').length.should.equal(1)54 handles.with_text('HLSL SEQ. NO. 2 ').length.should.equal(1)55 handles.with_text('HLSL SEQ. NO. 3 ').length.should.equal(1)56 handles.with_text('HLSL SEQ. NO. 4 ').length.should.equal(1)57 handles.with_text('HLSL SEQ. NO. 5 ').length.should.equal(1)58 handles.with_text('HLSL SEQ. NO. 6 ').length.should.equal(1)59 handles.with_text('HLSL SEQ. NO. 7 ').length.should.equal(1)60 handles.with_text('HLSL SEQ. NO. 8 ').length.should.equal(1)61 handles.with_text('HLSL SEQ. NO. 9 ').length.should.equal(1)62 handles.with_text('HLSL SEQ. NO. 10 ').length.should.equal(1)63 # test not repeating page numbers after64 page = seq(330)65 page('.page-handle').length.should.equal(20)66 page('.page-handle').with_text('HLSL SEQ. NO. 340').length.should.equal(1)67 text = page('.page-handle').text()68 for i in range(321,341):69 text.should.contain('HLSL Seq. No. {}'.format(i))70 page = seq(150)71 page('.page-handle').with_text('HLSL SEQ. NO. 160').length.should.equal(1)72def test_seq_alignment(seq):73 # the first seq load for 40 and 49 should be the same74 page = seq(40)75 page('.page-handle').nth(0).text().should.contain('Seq. No. 31')76 page = seq(49)77 page('.page-handle').nth(0).text().should.contain('Seq. No. 31')78 # it begins on a join and should not have the first incomplete sentence from seq 3179 page.text().should_not.contain('directly responsible to Hitler himself is the defendant Karl Brandt')80 # the batch previous should end on the same join81 page = seq(25)82 page('.page-handle').nth(-1).text().should.contain('Seq. No. 30')83 page.text().should.contain('The only defendant in the dock who was directly responsible to Hitler himself is the defendant Karl Brandt.')84def test_go_to_date(seq):85 page = seq(100)86 page('.page-handle').with_text('10 DECEMBER 1946').should.not_be.empty87 page('select option').with_text('10 December 1946').attr('selected').should.be.true88 date_link = page('select option').with_text('29 January 1947')89 date_link.should.not_be.empty90 page = go_to(date_link.submit_value())91 page('.page-handle').with_text('29 JANUARY 1947').should.not_be.empty92def test_go_to_page(seq):93 page = seq(500)94 page('.page-handle').with_text('PAGE 482').should.not_be.empty95 page = go_to(page('form').with_text('Go to page:').find('input[type=number]').submit_value(4820))96 page('.page-handle').with_text('PAGE 4,820').should.not_be.empty97 # test guesstimation: page 5000 is unlabeled98 page = go_to(page('form').with_text('Go to page:').find('input[type=number]').submit_value(5000))99 page('.page-handle').with_text('PAGE 5,000').should.be.empty100 page('.page-handle').with_text('PAGE 4,999').should.not_be.empty101 page('.page-handle').with_text('PAGE 5,001').should.not_be.empty102def test_evidence_links(seq):103 # evidence file number104 page = seq(136)105 page = follow_link(page('a').with_text('NO-417'))106 page.text().should.contain('Results 1-2 of 2 for * evidence:"NO-417"')107 page.text().should.contain('Organizational chart of the SS Medical Service (from September 1943)')108 page = follow_link(page('.document-row').with_text('Transcript for NMT 1: Medical Case').find('a'))109 page.text().should.contain('3 pages with results')110def test_exhibit_links(seq):111 # prosecution exhibit number112 page = seq(210)113 page = follow_link(page('a').with_text('61'))114 page.text().should.contain('Results 1-5 of 5 for * exhibit:"Prosecution 61"')115 page.text().should.contain('Letter to Heinrich Himmler, sending report on high altitude experiments')116 page = follow_link(page('.document-row').with_text('Transcript for NMT 1: Medical Case').find('a'))117 page.text().should.contain('1 page with results')118 # defense exhibit number119 page = seq(6267)120 page = follow_link(page('a').with_text('8'))121 page.text().should.contain('Results 1-2 of 2 for * exhibit:"Rose 8"')122 page.text().should.contain('Extract from a report of a conference of consulting specialists, concerning dysentery')123 page = follow_link(page('.document-row').with_text('Transcript for NMT 1: Medical Case').find('a'))124 page.text().should.contain('2 pages with results')125def test_xml_import():126 abspath = path.dirname(path.abspath(__file__))127 transcript_page = TranscriptPage.objects.get(transcript_id=1, volume_id=1, volume_seq_number=136)128 transcript_page.seq_number.should.equal(136)129 transcript_page.date.should.equal(datetime(1946, 12, 10))130 transcript_page.page_number.should.equal(121)131 # ingest a dummy xml file132 out = call_command('ingest_transcript_xml', path.join(abspath, 'bad/NRMB-NMT01-01_00136_0.xml'))133 transcript_page = TranscriptPage.objects.get(transcript_id=1, volume_id=1, volume_seq_number=136)134 transcript_page.seq_number.should.equal(99999)135 transcript_page.date.should.equal(datetime(1999, 1, 1))136 transcript_page.page_number.should.equal(99999)137 transcript_page.text().should.contain('No text in here')138 transcript_page.extract_evidence_codes().should.be.empty139 transcript_page.extract_exhibit_codes().should.be.empty140 # ingest the correct xml file141 call_command('ingest_transcript_xml', path.join(abspath, 'good/NRMB-NMT01-01_00136_0.xml'))142 transcript_page = TranscriptPage.objects.get(transcript_id=1, volume_id=1, volume_seq_number=136)143 transcript_page.seq_number.should.equal(136)144 transcript_page.date.should.equal(datetime(1946, 12, 10))145 transcript_page.page_number.should.equal(121)146 transcript_page.text().should.contain('The defendants Karl Brandt, Genzken, Gebhardt, Rudolf Brandt')147 transcript_page.extract_evidence_codes().should.equal(['NO-416', 'NO-417'])...

Full Screen

Full Screen

test_api.py

Source:test_api.py Github

copy

Full Screen

1import pytest2import requests3import json4from grappa import should5class RestApi:6 def __init__(self, url: str):7 self._url = url8 def hello_world(self):9 return requests.get(f"{self._url}/")10 def understand_deprecated(self, text: str):11 return requests.get(f"{self._url}/understand?query={text}")12 def understand(self, text: str):13 return requests.post(f"{self._url}/understand", json.dumps({"text": text}))14# noinspection PyStatementEffect15@pytest.mark.integration16class TestRestApiDeprecated(object):17 @classmethod18 def setup_class(cls):19 cls._api = RestApi("http://localhost:9444")20 def test_hello_world(self):21 resp = self._api.hello_world()22 resp.ok | should.be.true23 def test_understand_deprecated__hello(self):24 resp = self._api.understand_deprecated("bonjour")25 resp.ok | should.be.true26 result = json.loads(resp.content)27 result["intents"] | should.not_be.empty28 result["intents"][0]['label'] | should.be.equal.to('HELLO')29 result["entities"] | should.be.empty30 def test_understand_deprecated__time(self):31 resp = self._api.understand_deprecated("quelle heure il est")32 resp.ok | should.be.true33 result = json.loads(resp.content)34 result["intents"] | should.not_be.empty35 result["intents"][0]['label'] | should.be.equal.to('GET_TIME')36 result["entities"] | should.be.empty37 def test_understand__hello(self):38 resp = self._api.understand("bonjour")39 resp.ok | should.be.true40 result = json.loads(resp.content)41 result["intents"] | should.not_be.empty42 result["intents"][0]['label'] | should.be.equal.to('HELLO')43 result["entities"] | should.be.empty44 def test_understand__time(self):45 resp = self._api.understand("quelle heure il est")46 resp.ok | should.be.true47 result = json.loads(resp.content)48 result["intents"] | should.not_be.empty49 result["intents"][0]['label'] | should.be.equal.to('GET_TIME')50 result["entities"] | should.be.empty51 def test_understand__shopping_list(self):52 resp = self._api.understand("ajoute des fraises à ma liste")53 resp.ok | should.be.true54 result = json.loads(resp.content)55 result["intents"] | should.not_be.empty56 result["intents"][0]['label'] | should.be.equal.to('ADD_TO_LIST')57 result["entities"] | should.not_be.empty58 result["entities"][0] | should.be.equal.to({'label': 'SHOPITEM', 'text': 'fraises'})59 def test_understand__trigger_shopping_list(self):60 resp = self._api.understand("on fait la liste de course")61 resp.ok | should.be.true62 result = json.loads(resp.content)63 result["intents"] | should.not_be.empty64 result["intents"][0]['label'] | should.be.equal.to('TRIGGER_SHOPPING_LIST')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Sure automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful