Exemple #1
0
    def test_create_auth(self):
        """Call ``create`` and specify the ``auth`` argument.

        Assert that the values provided for the ``auth`` argument are passed to
        :func:`robottelo.api.client.post`.

        """
        client.post = Mock(return_value=MockResponse())
        auth = (
            FauxFactory.generate_string('utf8', 10),  # username
            FauxFactory.generate_string('utf8', 10),  # password
        )
        SampleFactory().create(auth=auth)
        self.assertEqual(auth, client.post.call_args[1]['auth'])
Exemple #2
0
 def setUp(self):
     self.path = FauxFactory.generate_string(
         'utf8',
         FauxFactory.generate_integer(min_value=1, max_value=100)
     )
     self.desired = FauxFactory.generate_integer()
     self.response = MockResponse()
Exemple #3
0
 def get_value(self):
     """Return a value suitable for a :class:`StringField`."""
     return _get_value(
         self,
         lambda: FauxFactory.generate_string(
             FauxFactory.generate_choice(self.str_type),
             FauxFactory.generate_integer(1, self.max_len)
         )
     )
Exemple #4
0
    def _generate_name(self):
        """
        Generates a random name string.

        :return: A random string of random length.
        :rtype: str
        """

        name = unicode(FauxFactory.generate_string(
            FauxFactory.generate_choice(['alpha', 'cjk', 'latin1', 'utf8']),
            FauxFactory.generate_integer(1, 30)))

        return name
Exemple #5
0
    def test_get_search(self):
        """@Test: GET ``api/v2/hosts`` and specify the ``search`` parameter.

        @Feature: Host
        @Assert: HTTP 200 is returned, along with ``search`` term.

        """
        query = FauxFactory.generate_string(
            'utf8',
            FauxFactory.generate_integer(1, 100)
        )
        response = client.get(
            entities.Host().path(),
            auth=get_server_credentials(),
            params={'search': query},
            verify=False,
        )
        self.assertEqual(response.status_code, httplib.OK)
        self.assertEqual(response.json()['search'], query)