def test_urlencode_catches_invalid_input():
    """Show that queries are loosely validated."""
    with pytest.raises(ValueError):
        urlencode(['fo'])

    with pytest.raises(ValueError):
        urlencode([('foo', 'bar', 'bogus')])
Exemplo n.º 2
0
def test_urlencode_catches_invalid_input():
    """Show that queries are loosely validated."""
    with pytest.raises(ValueError):
        urlencode(['fo'])

    with pytest.raises(ValueError):
        urlencode([('foo', 'bar', 'bogus')])
Exemplo n.º 3
0
    def test_reference_widgets_content_is_sorted(self, browser):
        self.login(self.dossier_responsible, browser)

        repo = create(Builder('repository')
                      .having(title_de=u'drittes repo')
                      .within(self.repository_root))

        self.repository_root.moveObjectsUp(repo.id)
        self.repository_root.moveObjectsUp(repo.id)

        contenttree_url = '/'.join((
            self.dossier.absolute_url(),
            '@@move_items',
            '++widget++form.widgets.destination_folder',
            '@@contenttree-fetch',
        ))
        browser.open(
            contenttree_url,
            headers={'Content-Type': 'application/x-www-form-urlencoded'},
            data=formdata.urlencode({
                'href': '/'.join(self.repository_root.getPhysicalPath()),
                'rel': 0,
            }),
        )

        selectables = browser.css('li.selectable').text

        self.assertEquals(
            ['fuhrung', 'rechnungsprufungskommission', 'drittes-repo'],
            selectables)
Exemplo n.º 4
0
    def test_reference_widgets_content_is_sorted(self, browser):
        self.login(self.dossier_responsible, browser)

        repo = create(
            Builder('repository').having(title_de=u'drittes repo').within(
                self.repository_root))

        self.repository_root.moveObjectsUp(repo.id)
        self.repository_root.moveObjectsUp(repo.id)

        contenttree_url = '/'.join((
            self.dossier.absolute_url(),
            '@@move_items',
            '++widget++form.widgets.destination_folder',
            '@@contenttree-fetch',
        ))
        browser.open(
            contenttree_url,
            headers={'Content-Type': 'application/x-www-form-urlencoded'},
            data=formdata.urlencode({
                'href':
                '/'.join(self.repository_root.getPhysicalPath()),
                'rel':
                0,
            }),
        )

        selectables = browser.css('li.selectable').text

        self.assertEquals(
            ['fuhrung', 'rechnungsprufungskommission', 'drittes-repo'],
            selectables)
Exemplo n.º 5
0
    def test_add_form_does_not_list_shadow_documents_as_relatable(self, browser):
        """Dossier responsible has created the shadow document.

        This test ensures he does not get it offered as a relatable document on
        tasks.
        """
        self.login(self.dossier_responsible, browser)
        contenttree_url = '/'.join((
            self.dossier.absolute_url(),
            '++add++opengever.task.task',
            '++widget++form.widgets.relatedItems',
            '@@contenttree-fetch',
        ))
        browser.open(
            contenttree_url,
            headers={'Content-Type': 'application/x-www-form-urlencoded'},
            data=formdata.urlencode({'href': '/'.join(self.dossier.getPhysicalPath()), 'rel': 0}),
        )
        expected_documents = [
            '2015',
            '2016',
            '[No Subject]',
            u'Antrag f\xfcr Kreiselbau',
            u'Die B\xfcrgschaft',
            u'Diskr\xe4te Dinge',
            u'Initialvertrag f\xfcr Bearbeitung',
            u'Initialvertrag f\xfcr Bearbeitung',
            'Personaleintritt',
            u're: Diskr\xe4te Dinge',
            u'Vertr\xe4ge',
            u'Vertr\xe4gsentwurf',
            u'Vertragsentwurf \xdcberpr\xfcfen',
            u'Vertragsentw\xfcrfe 2018',
        ]
        self.assertEqual(expected_documents, browser.css('li').text)
Exemplo n.º 6
0
    def test_add_form_does_not_list_shadow_documents_as_relatable(self, browser):
        """Dossier responsible has created the shadow document.

        This test ensures he does not get it offered as a relatable document on
        proposals.
        """
        self.login(self.dossier_responsible, browser)
        contenttree_url = '/'.join((
            self.dossier.absolute_url(),
            '++add++opengever.meeting.proposal',
            '++widget++form.widgets.relatedItems',
            '@@contenttree-fetch',
        ))
        browser.open(
            contenttree_url,
            headers={'Content-Type': 'application/x-www-form-urlencoded'},
            data=formdata.urlencode({'href': '/'.join(self.dossier.getPhysicalPath()), 'rel': 0}),
        )
        expected_documents = [
            '2015',
            '2016',
            '[No Subject]',
            u'Antrag f\xfcr Kreiselbau',
            u'Die B\xfcrgschaft',
            u'Diskr\xe4te Dinge',
            u'Initialvertrag f\xfcr Bearbeitung',
            u'Initialvertrag f\xfcr Bearbeitung',
            'Personaleintritt',
            u're: Diskr\xe4te Dinge',
            u'Vertr\xe4ge',
            u'Vertr\xe4gsentwurf',
            u'Vertragsentwurf \xdcberpr\xfcfen',
            u'Vertragsentw\xfcrfe 2018',
        ]
        self.assertEqual(expected_documents, browser.css('li').text)
Exemplo n.º 7
0
 def test_proposal_creation_lists_sibling_proposal_documents_as_attachables(
         self, browser):
     self.login(self.dossier_responsible, browser)
     browser.open(self.dossier)
     factoriesmenu.add('Proposal')
     contenttree_url = '/'.join((
         self.dossier.absolute_url(),
         '++add++opengever.meeting.proposal',
         '++widget++form.widgets.relatedItems',
         '@@contenttree-fetch',
     ))
     browser.open(
         contenttree_url,
         headers={'Content-Type': 'application/x-www-form-urlencoded'},
         data=formdata.urlencode({
             'href':
             '/'.join(self.dossier.getPhysicalPath()),
             'rel':
             0
         }),
     )
     containers = browser.css('li.navTreeFolderish').text
     selectables = browser.css('li.selectable').text
     self.assertIn(self.proposal.title, containers)
     for document in self.proposal.get_documents():
         self.assertIn(document.title, selectables)
Exemplo n.º 8
0
 def test_add_form_does_not_list_non_docx_documents_as_proposal_documents(self, browser):
     self.login(self.regular_user, browser)
     contenttree_url = '/'.join((
         self.dossier.absolute_url(),
         '++add++opengever.meeting.proposal',
         '++widget++form.widgets.proposal_document',
         '@@contenttree-fetch',
     ))
     browser.open(
         contenttree_url,
         headers={'Content-Type': 'application/x-www-form-urlencoded'},
         data=formdata.urlencode({'href': '/'.join(self.dossier.getPhysicalPath()), 'rel': 0}),
     )
     expected_documents = [u'Initialvertrag f\xfcr Bearbeitung', u'Vertr\xe4gsentwurf']
     self.assertEqual(expected_documents, browser.css('li').text)
Exemplo n.º 9
0
 def test_creating_proposal_from_tabbedview_sets_attachments(self, browser):
     self.login(self.regular_user, browser)
     browser.open(self.dossier, view='tabbedview_view-documents-proxy')
     original_template = ('orig_template', '#'.join((self.dossier.absolute_url(), 'documents')), )
     authenticator = ('_authenticator', createToken(), )
     document_14_path = ('paths:list', browser.css('#document-14').first.node.attrib.get('value'), )
     document_35_path = ('paths:list', browser.css('#document-35').first.node.attrib.get('value'), )
     method = ('++add++opengever.meeting.proposal:method', '1', )
     browser.open(
         self.dossier.absolute_url(),
         headers={'Content-Type': 'application/x-www-form-urlencoded'},
         data=formdata.urlencode((original_template, authenticator, document_14_path, document_35_path, method, )),
         )
     self.assertEqual(
         [u'Vertr\xe4gsentwurf', 'Feedback zum Vertragsentwurf'],
         browser.css('#form-widgets-relatedItems span.label').text,
         )
Exemplo n.º 10
0
    def test_add_form_does_not_list_shadow_documents_as_proposal_documents(self, browser):
        """Dossier responsible has created the shadow document.

        This test ensures he does not get it offered as a proposal document on
        proposals.
        """
        self.login(self.dossier_responsible, browser)
        contenttree_url = '/'.join((
            self.dossier.absolute_url(),
            '++add++opengever.meeting.proposal',
            '++widget++form.widgets.proposal_document',
            '@@contenttree-fetch',
        ))
        browser.open(
            contenttree_url,
            headers={'Content-Type': 'application/x-www-form-urlencoded'},
            data=formdata.urlencode({'href': '/'.join(self.dossier.getPhysicalPath()), 'rel': 0}),
        )
        expected_documents = [u'Initialvertrag f\xfcr Bearbeitung', u'Vertr\xe4gsentwurf']
        self.assertEqual(expected_documents, browser.css('li').text)
Exemplo n.º 11
0
def test_urlencode_flattens_nested_structures(query):
    """Show that when parsed, the structure is conveniently flat."""
    parsed = parse_qs(urlencode(query))

    assert parsed == expected_parsed_query
Exemplo n.º 12
0
arrivals = []

while True:
    time.sleep(5)
    ## REQUEST BUS STOP DATA
    url = 'https://openbus.emtmadrid.es:9443/emt-proxy-server/last/geo/GetArriveStop.php'
    query = {
        "idClient": "*****@*****.**",
        "passKey": "A6C8FC19-2A93-4CCB-AA8C-D044CF02D934",
        "idStop": "1887",
        "cultureInfo": "ES"
    }
    resp = requests.post(
        url,
        data=formdata.urlencode(query),
        headers={'Content-Type': 'application/x-www-form-urlencoded'},
    )

    data = resp.json()
    data_mock = {
        "arrives": [{
            "stopId": 1887,
            "lineId": "3",
            "isHead": "False",
            "destination": "SAN AMARO",
            "busId": "4615",
            "busTimeLeft": 10,
            "busDistance": 0,
            "longitude": -3.7113742223573,
            "latitude": 40.406431234994,
def test_urlencode_flattens_nested_structures(query):
    """Show that when parsed, the structure is conveniently flat."""
    parsed = parse_qs(urlencode(query))

    assert parsed == expected_parsed_query