<commit_before>from mock import MagicMock
import pyaem
import unittest

class TestPyAem(unittest.TestCase):


  def test_init(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    self.assertTrue(hasattr(aem, 'content_repo'))
    self.assertTrue(hasattr(aem, 'package_manager'))
    self.assertTrue(hasattr(aem, 'web_console'))


  def test_init_ssl_debug(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502, use_ssl = True, debug = True)
    self.assertTrue(hasattr(aem, 'content_repo'))
    self.assertTrue(hasattr(aem, 'package_manager'))
    self.assertTrue(hasattr(aem, 'web_console'))


  def test_create_path(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.content_repo.create_path = MagicMock()
    
    aem.create_path('some/path')
    aem.content_repo.create_path.assert_called_once_with('some/path')


if __name__ == '__main__':
  unittest.main()<commit_msg>Add web_console, package_manager, and the rest of content_repo delegation tests.<commit_after>from mock import MagicMock
import pyaem
import unittest

class TestPyAem(unittest.TestCase):


  def test_init(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    self.assertTrue(hasattr(aem, 'content_repo'))
    self.assertTrue(hasattr(aem, 'package_manager'))
    self.assertTrue(hasattr(aem, 'web_console'))


  def test_init_ssl_debug(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502, use_ssl = True, debug = True)
    self.assertTrue(hasattr(aem, 'content_repo'))
    self.assertTrue(hasattr(aem, 'package_manager'))
    self.assertTrue(hasattr(aem, 'web_console'))


  # content repo methods


  def test_create_path(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.content_repo.create_path = MagicMock()

    aem.create_path('/content/somepath')
    aem.content_repo.create_path.assert_called_once_with('/content/somepath')


  def test_activate_path(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.content_repo.activate_path = MagicMock()

    aem.activate_path('/content/somepath')
    aem.content_repo.activate_path.assert_called_once_with('/content/somepath')


  def test_create_user(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.content_repo.create_user = MagicMock()

    aem.create_user('/home/users/u/', 'someusername1', '<PASSWORD>')
    aem.content_repo.create_user.assert_called_once_with('/home/users/u/', 'someusername1', '<PASSWORD>')


  def test_add_user_to_group(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.content_repo.add_user_to_group = MagicMock()

    aem.add_user_to_group('someusername1', '/home/groups/g/', 'somegroupname1')
    aem.content_repo.add_user_to_group.assert_called_once_with('someusername1', '/home/groups/g/', 'somegroupname1')


  def test_create_group(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.content_repo.create_group = MagicMock()

    aem.create_group('/home/groups/g/', 'somegroupname1')
    aem.content_repo.create_group.assert_called_once_with('/home/groups/g/', 'somegroupname1')


  def test_change_password(self):

    aem = pyaem.PyAem('someusername', '<PASSWORD>', 'localhost', 4502)
    aem.content_repo.change_password = MagicMock()

    aem.change_password('/home/users/u/', 'someusername1', '<PASSWORD>', '<PASSWORD>')
    aem.content_repo.change_password.assert_called_once_with('/home/users/u/', 'someusername1', '<PASSWORD>', '<PASSWORD>')


  def test_set_permission(self):

    aem = pyaem.PyAem('someusername', '<PASSWORD>', 'localhost', 4502)
    aem.content_repo.set_permission = MagicMock()

    aem.set_permission('someusername1')
    aem.content_repo.set_permission.assert_called_once_with('someusername1')


  def test_set_agent(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.content_repo.set_agent = MagicMock()

    aem.set_agent('someagentname', 'somerunmode')
    aem.content_repo.set_agent.assert_called_once_with('someagentname', 'somerunmode')


  # package manager methods


  def test_create_package(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.package_manager.create_package = MagicMock()

    aem.create_package('somegroup', 'somepackage', '1.2-SNAPSHOT')
    aem.package_manager.create_package.assert_called_once_with('somegroup', 'somepackage', '1.2-SNAPSHOT')


  def test_update_package(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.package_manager.update_package = MagicMock()

    aem.update_package('somegroup', 'somepackage', '1.2-SNAPSHOT')
    aem.package_manager.update_package.assert_called_once_with('somegroup', 'somepackage', '1.2-SNAPSHOT')


  def test_build_package(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.package_manager.build_package = MagicMock()

    aem.build_package('somegroup', 'somepackage', '1.2-SNAPSHOT')
    aem.package_manager.build_package.assert_called_once_with('somegroup', 'somepackage', '1.2-SNAPSHOT')


  def test_download_package(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.package_manager.download_package = MagicMock()

    aem.download_package('somegroup', 'somepackage', '1.2-SNAPSHOT', '/some/path/')
    aem.package_manager.download_package.assert_called_once_with('somegroup', 'somepackage', '1.2-SNAPSHOT', '/some/path/')


  def test_upload_package(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.package_manager.upload_package = MagicMock()

    aem.upload_package('somegroup', 'somepackage', '1.2-SNAPSHOT', '/some/path/')
    aem.package_manager.upload_package.assert_called_once_with('somegroup', 'somepackage', '1.2-SNAPSHOT', '/some/path/')


  def test_build_package(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.package_manager.build_package = MagicMock()

    aem.build_package('somegroup', 'somepackage', '1.2-SNAPSHOT')
    aem.package_manager.build_package.assert_called_once_with('somegroup', 'somepackage', '1.2-SNAPSHOT')


  def test_install_package(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.package_manager.install_package = MagicMock()

    aem.install_package('somegroup', 'somepackage', '1.2-SNAPSHOT')
    aem.package_manager.install_package.assert_called_once_with('somegroup', 'somepackage', '1.2-SNAPSHOT')


  def test_replicate_package(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.package_manager.replicate_package = MagicMock()

    aem.replicate_package('somegroup', 'somepackage', '1.2-SNAPSHOT')
    aem.package_manager.replicate_package.assert_called_once_with('somegroup', 'somepackage', '1.2-SNAPSHOT')


  # web console methods


  def test_start_bundle(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.web_console.start_bundle = MagicMock()

    aem.start_bundle('somebundle')
    aem.web_console.start_bundle.assert_called_once_with('somebundle')


  def test_stop_bundle(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.web_console.stop_bundle = MagicMock()

    aem.stop_bundle('somebundle')
    aem.web_console.stop_bundle.assert_called_once_with('somebundle')


  def test_install_bundle(self):

    aem = pyaem.PyAem('someusername', 'somepassword', 'localhost', 4502)
    aem.web_console.install_bundle = MagicMock()

    aem.install_bundle('somebundle', '1.2-SNAPSHOT')
    aem.web_console.install_bundle.assert_called_once_with('somebundle', '1.2-SNAPSHOT')


if __name__ == '__main__':
  unittest.main()
{'fraction_non_alphanumeric': 0.1439413103971667, 'fraction_numerical': 0.01821401467240071, 'mean_word_length': 5.4024291497975705, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2052577', 'n_tokens_mistral': 2898, 'n_tokens_neox': 2759, 'n_words': 381}