Exemplo n.º 1
0
 def test_get_whoami_default_path(self):
     """
     Ensure that a dict is returned from reading a file in the default
     location.
     """
     mock_fd = mock.MagicMock
     mock_fd.read = mock.MagicMock(return_value='{}')
     path = os.path.join(data_dir(), 'whoami.json')
     with mock.patch('builtins.open', return_value=mock_fd) as mock_open:
         result = get_whoami()
         self.assertIsInstance(result, dict)
         self.assertEqual({}, result)
         mock_open.assert_called_once_with(path, 'r')
Exemplo n.º 2
0
 def test_get_whoami_default_path(self):
     """
     Ensure that a dict is returned from reading a file in the default
     location.
     """
     mock_fd = mock.MagicMock
     mock_fd.read = mock.MagicMock(return_value='{}')
     path = os.path.join(data_dir(), 'whoami.json')
     with mock.patch('builtins.open', return_value=mock_fd) as mock_open:
         result = get_whoami()
         self.assertIsInstance(result, dict)
         self.assertEqual({}, result)
         mock_open.assert_called_once_with(path, 'r')
Exemplo n.º 3
0
 def test_get_whoami_with_path(self):
     """
     Ensure that a dict is returned from reading a file from a given
     location.
     """
     mock_fd = mock.MagicMock
     mock_fd.read = mock.MagicMock(return_value='{}')
     path = '/foo/bar.json'
     with mock.patch('builtins.open', return_value=mock_fd) as mock_open:
         result = get_whoami(path)
         self.assertIsInstance(result, dict)
         self.assertEqual({}, result)
         mock_open.assert_called_once_with(path, 'r')
Exemplo n.º 4
0
 def test_get_whoami_with_path(self):
     """
     Ensure that a dict is returned from reading a file from a given
     location.
     """
     mock_fd = mock.MagicMock
     mock_fd.read = mock.MagicMock(return_value='{}')
     path = '/foo/bar.json'
     with mock.patch('builtins.open', return_value=mock_fd) as mock_open:
         result = get_whoami(path)
         self.assertIsInstance(result, dict)
         self.assertEqual({}, result)
         mock_open.assert_called_once_with(path, 'r')