Beispiel #1
0
    def test_get_request_dict_wrong_headers(self):
        req = Requester('foo', 'bar')

        with self.assertRaises(AssertionError) as na:
            req.get_request_dict(params={}, data=None, headers='wrong')
        self.assertTrue(
            str(na.exception) == "headers must be a dict, got 'wrong'")
    def test_get_request_dict_wrong_headers(self):
        req = Requester('foo', 'bar')

        with self.assertRaises(AssertionError) as na:
            req.get_request_dict(
                params={},
                data=None,
                headers='wrong'
            )
        self.assertTrue(str(na.exception) == "headers must be a dict, got 'wrong'")
def test_get_request_dict_wrong_headers():
    req = Requester('foo', 'bar')

    with pytest.raises(AssertionError) as na:
        req.get_request_dict(
            params={},
            data=None,
            headers='wrong'
        )
    assert "headers must be a dict, got 'wrong'" in str(na.value)
Beispiel #4
0
    def test_get_request_dict_wrong_params(self):
        req = Requester('foo', 'bar')

        with self.assertRaises(AssertionError) as na:
            req.get_request_dict(
                params='wrong',
                data=None,
                headers=None
            )
        self.assertTrue(na.exception.message == "Params must be a dict, got 'wrong'")
Beispiel #5
0
def test_get_request_dict_auth():
    req = Requester('foo', 'bar')

    req_return = req.get_request_dict(params={}, data=None, headers=None)
    assert isinstance(req_return, dict)
    assert req_return.get('auth')
    assert req_return['auth'] == ('foo', 'bar')
Beispiel #6
0
    def test_get_request_dict_auth(self):
        req = Requester('foo', 'bar')

        req_return = req.get_request_dict(url='http://', params={}, data=None,
                headers=None)
        self.assertTrue(isinstance(req_return, dict))
        self.assertTrue(req_return.get('auth'))
        self.assertTrue(req_return['auth']==('foo', 'bar'))
Beispiel #7
0
    def test_get_request_dict_wrong_headers(self):
        req = Requester('foo', 'bar')

        with self.assertRaises(AssertionError) as na:
            req_return = req.get_request_dict(url='http://', params={}, 
                data=None, headers='wrong')
        self.assertTrue(
                na.exception.message=="headers must be a dict, got 'wrong'")
Beispiel #8
0
def test_get_request_dict_cookie():
    req = Requester('foo', 'bar')

    req_return = req.get_request_dict(params={}, data=None, headers=None)
    assert isinstance(req_return, dict)
    assert req_return.get('headers')
    assert req_return.get('headers').get('Cookie')
    assert req_return.get('headers').get('Cookie') == 'FAKE'
Beispiel #9
0
def test_get_request_dict_data_not_passed():
    req = Requester('foo', 'bar')

    req_return = req.get_request_dict(params={'param': 'value'},
                                      data=None,
                                      headers={'header': 'value'})

    assert isinstance(req_return, dict)
    assert req_return.get('data') is None
Beispiel #10
0
    def test_get_request_dict_data_not_passed(self):
        req = Requester('foo', 'bar')

        req_return = req.get_request_dict(params={'param': 'value'},
                                          data=None,
                                          headers={'header': 'value'})

        self.assertTrue(isinstance(req_return, dict))
        self.assertFalse(req_return.get('data'))
Beispiel #11
0
    def test_get_request_dict_data_not_passed(self):
        req = Requester('foo', 'bar')

        req_return = req.get_request_dict(url='http://', 
            params={'param': 'value'},
            data=None, headers={'header': 'value'})

        self.assertTrue(isinstance(req_return, dict))
        self.assertFalse(req_return.get('data'))
Beispiel #12
0
def test_get_request_dict_correct_headers():
    req = Requester('foo', 'bar')

    req_return = req.get_request_dict(params={'param': 'value'},
                                      data=None,
                                      headers={'header': 'value'})

    assert isinstance(req_return, dict)
    assert req_return.get('headers')
    assert req_return['headers'] == {'header': 'value'}
    def test_get_request_dict_wrong_headers(self):
        req = Requester('foo', 'bar')

        with self.assertRaises(AssertionError) as na:
            req_return = req.get_request_dict(url='http://',
                                              params={},
                                              data=None,
                                              headers='wrong')
        self.assertTrue(
            na.exception.message == "headers must be a dict, got 'wrong'")
    def test_get_request_dict_auth(self):
        req = Requester('foo', 'bar')

        req_return = req.get_request_dict(url='http://',
                                          params={},
                                          data=None,
                                          headers=None)
        self.assertTrue(isinstance(req_return, dict))
        self.assertTrue(req_return.get('auth'))
        self.assertTrue(req_return['auth'] == ('foo', 'bar'))
Beispiel #15
0
    def test_get_request_dict_correct_headers(self):
        req = Requester('foo', 'bar')

        req_return = req.get_request_dict(url='http://', 
            params={'param': 'value'},
            data=None, headers={'header': 'value'})

        self.assertTrue(isinstance(req_return, dict))
        self.assertTrue(req_return.get('headers'))
        self.assertTrue(req_return['headers']=={'header': 'value'})
Beispiel #16
0
def test_get_request_dict_nocookie():
    req = Requester('foo', 'bar')

    req_return = req.get_request_dict(
        params={},
        data=None,
        headers=None
    )
    assert isinstance(req_return, dict)
    assert not req_return.get('headers')
Beispiel #17
0
    def test_get_request_dict_correct_params(self):
        req = Requester('foo', 'bar')

        req_return = req.get_request_dict(params={'param': 'value'},
                                          data=None,
                                          headers=None)

        self.assertTrue(isinstance(req_return, dict))
        self.assertTrue(req_return.get('params'))
        self.assertTrue(req_return['params'] == {'param': 'value'})
Beispiel #18
0
    def test_get_request_dict_data_passed(self):
        req = Requester('foo', 'bar')

        req_return = req.get_request_dict(url='http://', 
            params={'param': 'value'},
            data='some data', headers={'header': 'value'})

        self.assertTrue(isinstance(req_return, dict))
        print req_return.get('data')
        self.assertTrue(req_return.get('data'))
        self.assertTrue(req_return['data']=='some data')
Beispiel #19
0
def test_get_request_dict_auth():
    req = Requester('foo', 'bar')

    req_return = req.get_request_dict(
        params={},
        data=None,
        headers=None
    )
    assert isinstance(req_return, dict)
    assert req_return.get('auth')
    assert req_return['auth'] == ('foo', 'bar')
Beispiel #20
0
def test_get_request_dict_data_not_passed():
    req = Requester('foo', 'bar')

    req_return = req.get_request_dict(
        params={'param': 'value'},
        data=None,
        headers={'header': 'value'}
    )

    assert isinstance(req_return, dict)
    assert req_return.get('data') is None
Beispiel #21
0
    def test_get_request_dict_data_passed(self):
        req = Requester('foo', 'bar')

        req_return = req.get_request_dict(params={'param': 'value'},
                                          data='some data',
                                          headers={'header': 'value'})

        self.assertTrue(isinstance(req_return, dict))
        # print(req_return.get('data'))
        self.assertTrue(req_return.get('data'))
        self.assertTrue(req_return['data'] == 'some data')
Beispiel #22
0
    def test_get_request_dict_correct_params(self):
        req = Requester('foo', 'bar')

        req_return = req.get_request_dict(
            params={'param': 'value'},
            data=None,
            headers=None
        )

        self.assertTrue(isinstance(req_return, dict))
        self.assertTrue(req_return.get('params'))
        self.assertEqual(req_return['params'], {'param': 'value'})
Beispiel #23
0
def test_get_request_dict_correct_headers():
    req = Requester('foo', 'bar')

    req_return = req.get_request_dict(
        params={'param': 'value'},
        data=None,
        headers={'header': 'value'}
    )

    assert isinstance(req_return, dict)
    assert req_return.get('headers')
    assert req_return['headers'] == {'header': 'value'}
Beispiel #24
0
def test_get_request_dict_updatecookie():
    req = Requester('foo', 'bar')

    req_return = req.get_request_dict(
        params={},
        data=None,
        headers={'key': 'value'}
    )
    assert isinstance(req_return, dict)
    assert req_return.get('headers')
    assert req_return.get('headers').get('key')
    assert req_return.get('headers').get('key') == 'value'
    assert req_return.get('headers').get('Cookie')
    assert req_return.get('headers').get('Cookie') == 'FAKE'
Beispiel #25
0
def test_get_request_dict_wrong_headers():
    req = Requester('foo', 'bar')

    with pytest.raises(AssertionError) as na:
        req.get_request_dict(params={}, data=None, headers='wrong')
    assert "headers must be a dict, got 'wrong'" in str(na.value)