def test_get_data(self, mock_mediator):
        """ The data variable is properly set."""

        expected = "Test Data"
        mock_instance = mock_mediator.return_value
        mock_instance.get_results.return_value = expected
        actual = Authenticator().data

        self.assertEqual(expected, actual)
    def test_init_sets_attributes(self, mock_mediator, mock_get_data):
        """ The instance variables call the appropriate methods."""

        Authenticator()

        with self.subTest():
            mock_mediator.assert_called_with(password='', username='')
        with self.subTest():
            mock_get_data.assert_called_with()
Exemplo n.º 3
0
    def test_init_sets_attributes(self, mock_mediator, mock_get_data):
        """ The instance variables call the appropriate methods."""

        test_data = {
            'username': '******',
            'password': '******'
        }
        Authenticator(**test_data)

        with self.subTest():
            mock_mediator.assert_called_with(**test_data)
        with self.subTest():
            mock_get_data.assert_called_with()
Exemplo n.º 4
0
    def test_auth_token_returned(self, mock_return):
        """ Authenticator should assign the token dictionary to the class member 'data'."""

        with open(os.path.join(
                PARENT_DIR + API_SAMPLES + "auth_sample.json")) as \
                json_data:
            self.auth_token_json = json.load(json_data)
        mock_return.request('POST',
                            AUTH_URL,
                            json=self.auth_token_json['response'])
        authenticator = Authenticator()

        expected = self.auth_token_json['response']
        actual = authenticator.data

        self.assertEqual(actual, expected)
Exemplo n.º 5
0
    def __init__(self, **request_parameters):
        """ Sets up the mediator and data attributes.

            The mediator is set to the mediator that it will be contacting.  The data
            is set to the DataFrame returned from the get_results method.

        """

        super().__init__(**request_parameters)
        self.request_parameters = request_parameters
        self.authenticator = Authenticator()
        self.request_parameters['auth_token'] = self.authenticator.data[
            'token']
        self.request_parameters['metric'] = self.METRIC_PATH
        self.mediator = GenericMediator(**self.request_parameters)
        self.data = self.get_data()