def test_nova_addadmintoserver(self, testbot):
        # Get base state
        testbot.push_message("!nova getusers --server-name smcquaid-dev2")
        response = testbot.pop_message()
        assert "dxstarr" not in response

        # Add User
        testbot.push_message("!nova addadmintoserver --user-name dxstarr --server-name smcquaid-dev2")
        response = testbot.pop_message(timeout=10)
        assert "Success" in response

        # Check state
        testbot.push_message("!nova getusers --server-name smcquaid-dev2")
        response = testbot.pop_message(timeout=10)
        assert "dxstarr" in response

        # Clean up
        testbot.push_message("!nova removeadminfromserver --user-name dxstarr --server-name smcquaid-dev2")
        response = testbot.pop_message(timeout=10)
        assert "Success" in response

        # Check base state
        testbot.push_message("!nova getusers --server-name smcquaid-dev2")
        response = testbot.pop_message(timeout=10)
        assert "dxstarr" not in response
Beispiel #2
0
def test_backup(testbot):
    bot = testbot.bot  # used while restoring
    bot.push_message('!repos install https://github.com/errbotio/err-helloworld.git')
    assert 'Installing' in testbot.pop_message()
    assert 'err-helloworld' in testbot.pop_message(timeout=60)
    assert 'reload' in testbot.pop_message()
    bot.push_message('!backup')
    msg = testbot.pop_message()
    assert 'has been written in' in msg
    filename = re.search(r"'([A-Za-z0-9_\./\\-]*)'", msg).group(1)

    # At least the backup should mention the installed plugin
    assert 'errbotio/err-helloworld' in open(filename).read()

    # Now try to clean the bot and restore
    for p in testbot.bot.plugin_manager.get_all_active_plugin_objects():
        p.close_storage()

    assert 'Plugin HelloWorld deactivated.' in testbot.exec_command('!plugin deactivate HelloWorld')

    plugins_dir = path.join(testbot.bot_config.BOT_DATA_DIR, 'plugins')
    bot.repo_manager['installed_repos'] = {}
    bot.plugin_manager['configs'] = {}
    rmtree(plugins_dir)
    mkdir(plugins_dir)

    # emulates the restore environment
    log = logging.getLogger(__name__)  # noqa
    with open(filename) as f:
        exec(f.read())

    assert 'Plugin HelloWorld activated.' in testbot.exec_command('!plugin activate HelloWorld')
    assert 'Hello World !' in testbot.exec_command('!hello')
    testbot.push_message('!repos uninstall errbotio/err-helloworld')
    def test_keystone_addadmintoproject(self, testbot):
        # Get base state
        testbot.push_message("!keystone listprojectusers --project-name dev-smcquaid")
        response = testbot.pop_message()
        assert "dxstarr" not in response

        # Add User
        testbot.push_message("!keystone addadmintoproject --user-name dxstarr --project-name dev-smcquaid")
        response = testbot.pop_message(timeout=10)
        assert "Success" in response
        # @TODO - need to use project ID for code coverage

        # Check state
        testbot.push_message("!keystone listprojectusers --project-name dev-smcquaid")
        response = testbot.pop_message(timeout=10)
        assert "dxstarr" in response

        # Clean up
        testbot.push_message("!keystone removeadminfromproject --user-name dxstarr --project-name dev-smcquaid")
        response = testbot.pop_message(timeout=10)
        assert "Success" in response

        # Check base state
        testbot.push_message("!keystone listprojectusers --project-name dev-smcquaid")
        response = testbot.pop_message(timeout=10)
        assert "dxstarr" not in response
 def test_whos_out(self, testbot):
     testbot.push_message("who's out?")
     msg = testbot.pop_message(0.2)
     assert len(msg) > 0
     assert 'Sarah Skiver:' in msg
     assert 'Charlie Brown:' in msg
     print(msg)
Beispiel #5
0
def webhook_testbot(request, testbot):
    testbot.push_message(
        "!plugin config Webserver {'HOST': 'localhost', 'PORT': %s, 'SSL': None}"
        % WEBSERVER_PORT)
    log.info(testbot.pop_message())
    wait_for_server(WEBSERVER_PORT)
    return testbot
Beispiel #6
0
 def test_kudos_stats(self, testbot):
     for username in USERNAMES:
         testbot.push_message('!{0}++'.format(username))
         testbot.pop_message()
         testbot.push_message('!kudos {0}'.format(username))
         assert '{0} has 1 kudo points'.format(
             username) in testbot.pop_message()
Beispiel #7
0
 def test_run_pomodoro_turn_to_rest(self, testbot):
     testbot.push_message('!pomodoro_start')
     time.sleep(0.5)
     plugin = self.fetch_plugin(testbot)
     runner = list(plugin._runners.keys())[0]
     [plugin.pomodoro() for _ in range(25)]
     assert plugin._runners[runner] == -5
Beispiel #8
0
 def test_legendary(self, testbot):
     # Has random, thus manually
     plugin = get_plugin(testbot, 'Evil')
     testbot.push_message("!legendary")
     result = testbot.pop_message()
     expected = plugin._Evil__legendaer
     assert result in expected
    def test_nova_getcreator(self, testbot):
        testbot.push_message("!nova getcreator --server-id d1264da8-b428-47f4-aefa-4d263236f403")
        response = testbot.pop_message(timeout=2)
        assert "smcquaid" in response

        testbot.push_message("!nova getcreator --server-name smcquaid-dev2")
        response = testbot.pop_message(timeout=2)
        assert "smcquaid" in response
Beispiel #10
0
 def test_start(self, testbot):
     testbot.push_message('!pomodoro_start')
     assert 'Start timer' in testbot.pop_message()
     plugin = self.fetch_plugin(testbot)
     assert len(plugin._runners) == 1
     assert isinstance(list(plugin._runners.keys())[0], str) is True
     id_ = testbot.bot.build_identifier(list(plugin._runners.keys())[0])
     assert isinstance(id_, Person) is True
Beispiel #11
0
    def test_dayinfo_specific_day(self, testbot):  # noqa
        testbot.push_message('!dayinfo 1.1.2016')
        msg = 'Friday 01.01.2016, Day of the Establishment of the Slovak ' \
              'Republic'
        assert msg in testbot.pop_message()

        testbot.push_message('!dayinfo 5.6.2014')
        assert 'Thursday 05.06.2014, Nameday: Laura' in testbot.pop_message()
Beispiel #12
0
 def test_install_plasmoid(self, testbot):
     testbot.push_message('!install_plasmoid')
     output = "Follow the plasmoid install guide" \
              "at, https://cgit.kde.org/plasma-mycroft.git/tree/Readme.md" \
              "If you are running an Ubuntu or Fedora based distribution" \
              "You can find the installation scripts" \
              "here, https://github.com/MycroftAI/installers"
     assert output in testbot.pop_message()
Beispiel #13
0
 def test_delete_kudos_user(self, testbot):
     for username in USERNAMES:
         testbot.push_message('!{0}++'.format(username))
         assert 'kudos updated for {0}'.format(username) \
                 in testbot.pop_message()
         testbot.push_message('!kudos delete_entries {0}'.format(username))
         assert 'Entries deleted for {0} user'.format(username) \
                 in testbot.pop_message()
Beispiel #14
0
 def test_delete_kudos_user(self, testbot):
     for username in USERNAMES:
         testbot.push_message('!{0}++'.format(username))
         assert 'kudos updated for {0}'.format(username) \
                 in testbot.pop_message()
         testbot.push_message('!kudos delete_entries {0}'.format(username))
         assert 'Entries deleted for {0} user'.format(username) \
                 in testbot.pop_message()
Beispiel #15
0
 def test_run_pomodoro_one_user(self, testbot):
     testbot.push_message('!pomodoro_start')
     time.sleep(0.5)
     plugin = self.fetch_plugin(testbot)
     runner = list(plugin._runners.keys())[0]
     plugin.pomodoro()
     assert plugin._runners[runner] == 1
     plugin.pomodoro()
     assert plugin._runners[runner] == 2
    def test_non_rt_url(self, testbot):
        testbot.push_message('!plugin config RT ' + str(RT_CONFIG))
        assert 'Plugin configuration done.' in testbot.pop_message()

        testbot.push_message('http://example.com?id=123')

        try:
            testbot.pop_message(block=False)
        except:
            pass
Beispiel #17
0
 def test_troubleshoot_plasmoid(self, testbot):
     testbot.push_message('!troubleshoot_plasmoid')
     output = "Steps to troubleshoot your plasmoid install" \
              "1: Check if mycroft is installed correctly" \
              "2: Open plasmoid settings and check your mycroft path" \
              "3: Run plasmashell in debug mode report error messages" \
              "4: Submit your issue's on the #desktop channel, or" \
              "5: Create a bug report at https://bugs.kde.org" \
              "/describecomponents.cgi?product=plasma-mycroft"
     assert output in testbot.pop_message()
    def test_keystone_listprojectusers(self, testbot):
        testbot.push_message("!keystone listprojectusers --project-name dev-smcquaid")
        response = testbot.pop_message(timeout=2)
        assert "dxstarr" not in response
        assert "smcquaid" in response

        # @TODO need to add test for listprojectusers by id
        testbot.push_message("!keystone listprojectusers --project-id 2e1d7ae656eb406891488643cd4ef922")
        response = testbot.pop_message(timeout=10)
        assert "dxstarr" not in response
        assert "smcquaid" in response
    def test_find_nonexistent_ticket(self, testbot):

        testbot.push_message('!plugin config RT ' + str(RT_CONFIG))
        assert 'Plugin configuration done.' in testbot.pop_message()

        tracker = rt.Rt(RT_CONFIG['REST_URL'])
        tracker.login(RT_CONFIG['USER'], RT_CONFIG['PASSWORD'])

        testbot.push_message('999999999999999999999999999999999999999999999')
        expected = "Sorry, that ticket does not exist or I cannot access it."
        assert expected in testbot.pop_message()
 def test_set_good_config_can_now_check_is_x_in(self, testbot):
     '''After setting config via chat, can ask whos out'''
     self.start_test_server(run_fn)
     testbot.push_message("""!plugin config HolidayBot {
     'BAMBOOHR_APIKEY': 'testApikey',
     'BAMBOOHR_HOST': 'http://localhost:8080',
     'BAMBOOHR_COMPANY': 'reynholm-industries'}""")
     check_reply("Plugin configuration done", testbot)
     testbot.push_message("Is Julie in?")
     check_reply(["could not find", "Julie"], testbot)
     self.stop_test_server()
Beispiel #21
0
def test_config_cycle(testbot):
    testbot.push_message('!plugin config Webserver')
    m = testbot.pop_message()
    assert 'Default configuration for this plugin (you can copy and paste this directly as a command)' in m
    assert 'Current configuration' not in m

    testbot.assertCommand("!plugin config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}",
                          'Plugin configuration done.')

    assert 'Current configuration' in testbot.exec_command('!plugin config Webserver')
    assert 'localhost' in testbot.exec_command('!plugin config Webserver')
 def test_set_config(self, testbot):
     '''Should allow a new config to be set and read'''
     testbot.push_message("""!plugin config HolidayBot {
     'BAMBOOHR_APIKEY': 'IchangedYou',
     'BAMBOOHR_HOST': 'IchangedYou',
     'BAMBOOHR_COMPANY': 'IchangedYou'}""")
     check_reply("Plugin configuration done", testbot)
     testbot.push_message("""!plugin config HolidayBot""")
     check_reply(["'BAMBOOHR_APIKEY': 'IchangedYou'",
                  "'BAMBOOHR_HOST': 'IchangedYou'",
                  "'BAMBOOHR_COMPANY': 'IchangedYou'"], testbot)
 def test_set_valid_config_but_bad_company(self, testbot):
     '''After setting a config with valid format but not served,
      can ask whos out, but should fail'''
     self.start_test_server(run_fn)
     testbot.push_message("""!plugin config HolidayBot {
     'BAMBOOHR_APIKEY': 'testApikey2',
     'BAMBOOHR_HOST': 'http://localhost:8080',
     'BAMBOOHR_COMPANY': 'not-a-real-company'}""")
     check_reply("Plugin configuration done", testbot)
     testbot.push_message("Is Julie in?")
     check_reply(["Unable to check"], testbot)
     self.stop_test_server()
    def test_nova_getmetadata(self, testbot):
        testbot.push_message("!nova getmetadata --server-id d1264da8-b428-47f4-aefa-4d263236f403")
        response = testbot.pop_message(timeout=2)
        assert "smcquaid" in response

        testbot.push_message("!nova getmetadata --server-name smcquaid-dev2")
        response = testbot.pop_message(timeout=2)
        assert "smcquaid" in response
        assert "26 - DEV-Private Cloud" in response
        assert "login_groups" in response
        assert "login_users" in response
        assert "owning_group" in response
        assert "smcquaid" in response
Beispiel #25
0
def test_config_cycle(testbot):
    testbot.push_message('!plugin config Webserver')
    m = testbot.pop_message()
    assert 'Default configuration for this plugin (you can copy and paste this directly as a command)' in m
    assert 'Current configuration' not in m

    testbot.assertCommand(
        "!plugin config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}",
        'Plugin configuration done.')

    assert 'Current configuration' in testbot.exec_command(
        '!plugin config Webserver')
    assert 'localhost' in testbot.exec_command('!plugin config Webserver')
    def test_find_ticket(self, testbot):
        test_subject = 'RT plugin for Errbot - automated test'
        test_requestor = '*****@*****.**'
        test_text = 'Testing https://github.com/alimac/err-request-tracker'

        testbot.push_message('!plugin config RT ' + str(RT_CONFIG))
        assert 'Plugin configuration done.' in testbot.pop_message()

        tracker = rt.Rt(RT_CONFIG['REST_URL'])
        tracker.login(RT_CONFIG['USER'], RT_CONFIG['PASSWORD'])

        try:
            ticket_id = tracker.create_ticket(Queue='General',
                                              Subject=test_subject,
                                              Requestors=test_requestor,
                                              Text=test_text)
            ticket = tracker.get_ticket(ticket_id)
        except Exception as e:
            raise Exception("Unable to create a test ticket: " + str(e))

        testbot.push_message(str(ticket_id))
        assert "%s (%s%s) in General from %s" % (
            test_subject, RT_CONFIG['DISPLAY_URL'], str(ticket_id),
            test_requestor) in testbot.pop_message()

        testbot.push_message(RT_CONFIG['DISPLAY_URL'] + str(ticket_id))
        assert "%s (%s%s) in General from %s" % (
            test_subject, RT_CONFIG['DISPLAY_URL'], str(ticket_id),
            test_requestor) in testbot.pop_message()

        testbot.push_message("need help with " + str(ticket_id))
        assert "%s (%s%s) in General from %s" % (
            test_subject, RT_CONFIG['DISPLAY_URL'], str(ticket_id),
            test_requestor) in testbot.pop_message()
    def test_addtag(self, testbot):
        # Test for empty argument string
        # Expected result: Print error message and proper syntax
        testbot.push_message('!diplomat addtag')
        expected = "Please include a tag and character name\nProper syntax is !diplomat addtag <tag> <name>"
        result = testbot.pop_message()
        assert expected == result

        # Test for single argument
        # Expected result: Print error message including proper syntax
        testbot.push_message('!diplomat addtag miniluv')
        expected = "Please include a name of a character to check.\nProper syntax is !diplomat addtag <tag> <name>"
        result = testbot.pop_message()
        assert expected == result

        # Test for adding to a character that does not exist
        # Expected result: Print error message stating character does not exist
        testbot.push_message('!diplomat addtag miniluv sjugar02')
        expected = "Character sjugar02 does not exist in Diplomat."
        result = testbot.pop_message()
        assert expected == result

        # Test for successfully adding a tag to an existing character
        # Expected result: Return message indicating the successful addition of
        # tag to character in Diplomat
        testbot.push_message('!diplomat addtag miniluv Boneytooth Thompkins isk-chip')
        expected = "Added tag 'miniluv' to character 'boneytooth thompkins isk-chip'"
        result = testbot.pop_message()
        assert expected == result
Beispiel #28
0
def test_history(testbot):
    assert 'up' in testbot.exec_command('!uptime')
    assert 'uptime' in testbot.exec_command('!history')

    orig_sender = testbot.bot.sender
    # Pretend to be someone else. History should be empty
    testbot.bot.sender = testbot.bot.build_identifier('non_default_person')
    testbot.push_message('!history')
    with pytest.raises(Empty):
        testbot.pop_message(timeout=1)
    assert 'should be a separate history' in testbot.exec_command('!echo should be a separate history')
    assert 'should be a separate history' in testbot.exec_command('!history')
    testbot.bot.sender = orig_sender
    # Pretend to be the original person again. History should still contain uptime
    assert 'uptime' in testbot.exec_command('!history')
Beispiel #29
0
    def test_what_mycroft(self, testbot):
        testbot.push_message('!what_mycroft')
        output = "Mycroft Core is the primary module that makes up the " \
                 "Mycroft Artificial Intelligence platform.  Mycroft makes " \
                 "use of the Adapt Intent Parser, Speech-to-Text software, " \
                 "and Text-to-Speech. The idea behind the platform " \
                 "is to be able to voice enable any device and turn " \
                 "it into a smart personal assistant, able to perform a " \
                 "variety of tasks. Mycroft is often used to refer " \
                 "to the hardware product produced by Mycroft AI, Inc. " \
                 "- so to avoid confusion, the software stack is " \
                 "often referred to as \"Mycroft Core\", more info can be " \
                 "found here, https://docs.mycroft.ai"

        assert output in testbot.pop_message()
    def test_isred(self, testbot):
        testbot.push_message('!diplomat isred')
        expected = "Please include a name of a character to check."
        result = testbot.pop_message()
        assert expected == result
        
        testbot.push_message('!diplomat isred Logical Fallacy')
        expected = "logical fallacy" + "\nStanding: 10.0" + \
                   "\nTags: cool, multiboxer, spy"
        result = testbot.pop_message()
        assert expected == result
        diplomat_plugin = testbot.bot.plugin_manager.get_plugin_obj_by_name('Diplomat')
        assert 'logical fallacy' in diplomat_plugin.diplomat
        assert 'spy' in diplomat_plugin.diplomat['logical fallacy']['tags']
        assert 'multiboxer' in diplomat_plugin.diplomat['logical fallacy']['tags']
        assert 'cool' in diplomat_plugin.diplomat['logical fallacy']['tags']
        assert diplomat_plugin.diplomat['logical fallacy']['standing'] == 10.0

        testbot.push_message('!diplomat isred Fabulous Andy')
        expected = "fabulous andy does not exist in Diplomat."
        result = testbot.pop_message()
        assert expected == result

        testbot.push_message('!diplomat isred Brad Neece')
        expected = "brad neece\nStanding: -5.0\nTags: annoying, edgey, misunderstood, summercamp, bff"
        result = testbot.pop_message()
        assert expected == result

        assert 'brad neece' in diplomat_plugin.diplomat
        assert 'annoying' in diplomat_plugin.diplomat['brad neece']['tags']
        assert 'edgey' in diplomat_plugin.diplomat['brad neece']['tags']
        assert 'misunderstood' in diplomat_plugin.diplomat['brad neece']['tags']
        assert 'summercamp' in diplomat_plugin.diplomat['brad neece']['tags']
        assert 'bff' in diplomat_plugin.diplomat['brad neece']['tags']
        assert diplomat_plugin.diplomat['brad neece']['standing'] == -5.0

        testbot.push_message('!diplomat isred warr akini')
        expected = "warr akini\nStanding: 10.0" +\
            "\nTags: cool, dick, butt, dickbutt"
        result = testbot.pop_message()
        assert expected == result

        assert 'warr akini' in diplomat_plugin.diplomat
        assert 'cool' in diplomat_plugin.diplomat['warr akini']['tags']
        assert 'dick' in diplomat_plugin.diplomat['warr akini']['tags']
        assert 'butt' in diplomat_plugin.diplomat['warr akini']['tags']
        assert 'dickbutt' in diplomat_plugin.diplomat['warr akini']['tags']
        assert diplomat_plugin.diplomat['warr akini']['standing'] == 10.0
Beispiel #31
0
def test_history(testbot):
    assert 'up' in testbot.exec_command('!uptime')
    assert 'uptime' in testbot.exec_command('!history')

    orig_sender = testbot.bot.sender
    # Pretend to be someone else. History should be empty
    testbot.bot.sender = testbot.bot.build_identifier('non_default_person')
    testbot.push_message('!history')
    with pytest.raises(Empty):
        testbot.pop_message(timeout=1)
    assert 'should be a separate history' in testbot.exec_command(
        '!echo should be a separate history')
    assert 'should be a separate history' in testbot.exec_command('!history')
    testbot.bot.sender = orig_sender
    # Pretend to be the original person again. History should still contain uptime
    assert 'uptime' in testbot.exec_command('!history')
    def test_nova_getusers(self, testbot):
        testbot.push_message("!nova getusers --server-id d1264da8-b428-47f4-aefa-4d263236f403")
        response = testbot.pop_message(timeout=2)
        assert "smcquaid" in response
        assert "dbingham" in response
        assert "jerobinson" in response
        assert "su_devcloud" in response
        assert "ac_devcloud" in response

        testbot.push_message("!nova getusers --server-name smcquaid-dev2")
        response = testbot.pop_message(timeout=2)
        assert "smcquaid" in response
        assert "dbingham" in response
        assert "jerobinson" in response
        assert "su_devcloud" in response
        assert "ac_devcloud" in response
 def test_is_x_in_using_hipchat_handle(self, testbot):
     testbot.push_message("is @SarahSkiver in?")
     check_reply('Sarah Skiver is currently on leave', testbot)
     testbot.push_message('where is @SarahSkiver?')
     check_reply('Sarah Skiver is currently on leave', testbot)
     testbot.push_message("is @Hugo in?")
     check_reply('Hugo Boss (hugs) is not on leave', testbot)
     testbot.push_message("is @WillSam in?")
     check_reply('Willem Samuel (Will) is not on leave', testbot)
Beispiel #34
0
    def test_arch_maint(self, testbot):
        # No argument
        dialogtest(
            testbot,
            '!arch maint',
            'Please specify a keyword.'
        )
        # No Dialogtest, we want to map using in!
        testbot.push_message('!arch maint faidoc')
        expected = ' packages maintained by faidoc found.\n\
cinnamon'
        result = testbot.pop_message()
        assert expected in result
        # Single arg without match
        dialogtest(
            testbot,
            '!arch maint foobarbaz',
            'No packages maintained by foobarbaz found.'
        )
Beispiel #35
0
    def test_forget_factoid(self, testbot):
        testbot.push_message('!sky is blue')
        assert 'Got it, sky is blue' in testbot.pop_message()

        testbot.push_message('sky?')
        assert 'sky is blue' in testbot.pop_message()

        testbot.push_message('!forget sky')
        assert 'OK, I forgot about sky' in testbot.pop_message()

        testbot.push_message('!list factoids')
        assert 'I have not learned any factoids yet.' in testbot.pop_message()
Beispiel #36
0
    def test_learn_factoid(self, testbot):
        testbot.push_message('!water is wet')
        assert 'Got it, water is wet' in testbot.pop_message()

        testbot.push_message('water?')
        assert 'water is wet' in testbot.pop_message()

        testbot.push_message('!water is hot')
        assert 'I already know about water.' in testbot.pop_message()

        testbot.push_message('!water is wet?')
        assert '/me does not know about water is wet' in testbot.pop_message()
Beispiel #37
0
    def test_klug(self, testbot):
        # empty
        dialogtest(
            testbot,
            '!klug',
            'Du bist so Kluk! K – L – U – K!'
        )
        # 1 arg:
        # Random, thus "in"!
        testbot.push_message('!klug pheerai')
        expected = 'Kluges pheerai! Hier hast du '
        result = testbot.pop_message()
        assert expected in result
        # 2 args:
        dialogtest(
            testbot,
            '!klug pheerai asdil1991',
            "Meine kleinen Schaltkreise können so viel Intelligenz \
nicht verkraften!"
        )
Beispiel #38
0
 def test_delete_kudos_list(self, testbot):
     testbot.push_message('!sijis++')
     assert 'kudos updated for sijis' in testbot.pop_message()
     testbot.push_message('!tom++')
     assert 'kudos updated for tom' in testbot.pop_message()
     testbot.push_message('!kudos list')
     assert 'sijis, tom' in testbot.pop_message()
    def test_removetag(self, testbot):
        # Test for empty argument string
        # Expected result: Print error message and proper syntax
        testbot.push_message('!diplomat remtag')
        expected = "Please include a tag and character name" + \
                   "\nProper syntax is !diplomat remtag <tag> <name>"
        result = testbot.pop_message()
        assert expected == result

        # Test for single argument
        # Expected result: Print error message including proper syntax
        testbot.push_message('!diplomat remtag miniluv')
        expected = "Please include a name of a character to remove a tag from." + \
                    "\nProper syntax is !diplomat remtag <tag> <name>"
        result = testbot.pop_message()
        assert expected == result

        # Test for removing a tag to a character that does not exist
        # Expected result: Print error message stating character does not exist
        testbot.push_message('!diplomat remtag miniluv sjugar02')
        expected = "Character sjugar02 does not exist in Diplomat."
        result = testbot.pop_message()
        assert expected == result

        # Test for removing a tag that doesn't exist from a character that exists
        # Expected result: returns message indicating that tag does not exist for specified character
        testbot.push_message('!diplomat remtag spy boneytooth thompkins isk-chip')
        expected = "Tag 'spy' does not exist for character 'boneytooth thompkins isk-chip'"
        result = testbot.pop_message()
        assert expected == result

        # Test for removing a tag that exists from a character that exists
        # Expected result: tag is removed
        # Returns a message indicating that the tag has been removed from the specified characters
        testbot.push_message('!diplomat remtag cool boneytooth thompkins isk-chip')
        expected = "Removed tag 'cool' from character 'boneytooth thompkins isk-chip'"
        result = testbot.pop_message()
        assert expected == result
        plugin = testbot.bot.plugin_manager.get_plugin_obj_by_name('Diplomat')
        assert 'spy' not in plugin.diplomat['boneytooth thompkins isk-chip']['tags']
Beispiel #40
0
 def test_command_alias_remove(self, testbot):
     testbot.push_message('!alias add s status')
     testbot.pop_message()
     testbot.push_message('!alias remove s')
     assert 'Alias removed.' in testbot.pop_message()
     testbot.push_message('!alias')
     assert '!s = !status' not in testbot.pop_message()
    def test_remchar(self, testbot):
        # Test for empty argument string
        # Expected result: Print error message and proper syntax
        testbot.push_message('!diplomat remchar')
        expected = "Please include the name of a character to remove from Diplomat." + \
                   "\nProper syntax is !diplomat remchar <name>"
        result = testbot.pop_message()
        assert expected == result

        # Test for character that does not exist
        # Expected result: Print error message, indicating character does not exist
        testbot.push_message('!diplomat remchar miniluv')
        expected = "miniluv does not exist in Diplomat."
        result = testbot.pop_message()
        assert expected == result

        # Test for removing character which exists
        # Expected result: Print message indicating the character has been removed
        # Character is removed from Diplomat.diplomat
        testbot.push_message('!diplomat remchar boneytooth thompkins isk-chip')
        expected = "Removed character 'boneytooth thompkins isk-chip' from Diplomat."
        result = testbot.pop_message()
        assert expected == result
        plugin = testbot.bot.plugin_manager.get_plugin_obj_by_name('Diplomat')
        assert 'boneytooth thompkins isk-chip' not in plugin.diplomat
Beispiel #42
0
 def test_delete_kudos_list(self, testbot):
     testbot.push_message('!sijis++')
     assert 'kudos updated for sijis' in testbot.pop_message()
     testbot.push_message('!tom++')
     assert 'kudos updated for tom' in testbot.pop_message()
     testbot.push_message('!kudos list')
     assert 'sijis, tom' in testbot.pop_message()
Beispiel #43
0
 def test_command_alias_remove(self, testbot):
     testbot.push_message('!alias add s status')
     testbot.pop_message()
     testbot.push_message('!alias remove s')
     assert 'Alias removed.' in testbot.pop_message()
     testbot.push_message('!alias')
     assert '!s = !status' not in testbot.pop_message()
 def test_invalid_config_after_good_one(self, testbot):
     '''Set bad config after setting a good one;
      check doesn't keep working'''
     self.start_test_server(run_fn)
     testbot.push_message("""!plugin config HolidayBot {
     'BAMBOOHR_APIKEY': 'testApikey',
     'BAMBOOHR_HOST': 'http://localhost:8080',
     'BAMBOOHR_COMPANY': 'reynholm-industries'}""")
     check_reply("Plugin configuration done", testbot)
     testbot.push_message("Is Julie in?")
     check_reply(["could not find", "Julie"], testbot)
     # Set a bad config (bad format)
     testbot.push_message("""!plugin config HolidayBot {
     'BAMBOOHR_APIKEY': 'changeme',
     'BAMBOOHR_HOST': 'https://api.bamboohr.com',
     'BAMBOOHR_COMPANY_hh': 'changeme'}""")
     check_reply("Plugin configuration done", testbot)
     # Plugin should be deactivated
     testbot.push_message("!status plugins")
     check_reply(["D      │ HolidayBot"], testbot)
     testbot.push_message("Is Julie in?")
     check_no_reply(testbot)
     self.stop_test_server()
Beispiel #45
0
def test_backup(testbot):
    bot = testbot.bot  # used while restoring
    bot.push_message(
        '!repos install https://github.com/errbotio/err-helloworld.git')
    assert 'Installing' in testbot.pop_message()
    assert 'err-helloworld' in testbot.pop_message(timeout=60)
    assert 'reload' in testbot.pop_message()
    bot.push_message('!backup')
    msg = testbot.pop_message()
    assert 'has been written in' in msg
    filename = re.search(r"'([A-Za-z0-9_\./\\-]*)'", msg).group(1)

    # At least the backup should mention the installed plugin
    assert 'errbotio/err-helloworld' in open(filename).read()

    # Now try to clean the bot and restore
    for p in testbot.bot.plugin_manager.get_all_active_plugin_objects():
        p.close_storage()

    assert 'Plugin HelloWorld deactivated.' in testbot.exec_command(
        '!plugin deactivate HelloWorld')

    plugins_dir = path.join(testbot.bot_config.BOT_DATA_DIR, 'plugins')
    bot.repo_manager['installed_repos'] = {}
    bot.plugin_manager['configs'] = {}
    rmtree(plugins_dir)
    mkdir(plugins_dir)

    # emulates the restore environment
    log = logging.getLogger(__name__)  # noqa
    with open(filename) as f:
        exec(f.read())

    assert 'Plugin HelloWorld activated.' in testbot.exec_command(
        '!plugin activate HelloWorld')
    assert 'Hello World !' in testbot.exec_command('!hello')
    testbot.push_message('!repos uninstall errbotio/err-helloworld')
Beispiel #46
0
    def test_list_factoids(self, testbot):
        testbot.push_message('!list factoids')
        assert 'I have not learned any factoids yet.' in testbot.pop_message()

        testbot.push_message('!water is wet')
        assert 'Got it, water is wet' in testbot.pop_message()

        testbot.push_message('!list factoids')
        assert "I'm Err! I know about:" in testbot.pop_message()
        assert 'water' in testbot.pop_message()
    def test_keystone_listservers(self, testbot):
        testbot.push_message("!keystone listservers --project-id f48e57277a7a484290ba9afdc49a21a9")
        response = testbot.pop_message(timeout=30)
        assert "smcquaid-dev" in response

        testbot.push_message("!keystone listservers --project-name openstack")
        response = testbot.pop_message(timeout=1)
        assert "smcquaid-dev" in response

        testbot.push_message("!keystone listservers")
        response = testbot.pop_message(timeout=1)
        assert "Too few arguments given" in response
    def test_valid_config_after_good_one(self, testbot):
        '''Set valid but wrong config after setting a good one;
         check doesn't keep working'''
        self.start_test_server(run_fn)
        testbot.push_message("""!plugin config HolidayBot {
        'BAMBOOHR_APIKEY': 'testApikey',
        'BAMBOOHR_HOST': 'http://localhost:8080',
        'BAMBOOHR_COMPANY': 'reynholm-industries'}""")
        check_reply("Plugin configuration done", testbot)
        testbot.push_message("Is Julie in?")
        check_reply(["could not find", "Julie"], testbot)
        
        # change to a valid but bad config
        testbot.push_message("""!plugin config HolidayBot {
        'BAMBOOHR_APIKEY': 'something',
        'BAMBOOHR_HOST': 'http://localhost:8080',
        'BAMBOOHR_COMPANY': 'unknown'}""")
        check_reply("Plugin configuration done", testbot)

        testbot.push_message("Is Julie in?")
        check_reply(["Unable to check", "An admin needs to configure credentials"], testbot)
        self.stop_test_server()
Beispiel #49
0
    def test_add_multistring_fite(self, testbot):
        """
        really stupid setup but trying to use normal
        setup methods and interfacing with the testbot
        is pita.  prob should just manually interact with
        mongo but don't give a shit
        """
        testbot.push_message('!toggle test')
        testbot.pop_message()


        testbot.push_message("!new fitelist warbar")
        assert "Fite Created" in testbot.pop_message()

        testbot.push_message("!add fite warbar | foo f**k | wtf omg")
        assert "foo f**k" in testbot.pop_message()
Beispiel #50
0
 def test_roll(self, testbot):
     testbot.push_message('!roll')
     testbot.pop_message()  # discard roll's start message
     result = testbot.pop_message().partition('... ')[2].partition('!')[0]
     assert (result == '1' or result == '2' or result == '3'
             or result == '4' or result == '5' or result == '6')
Beispiel #51
0
 def test_eightball(self, testbot):
     testbot.push_message('!eightball')
     result = testbot.pop_message()
     assert (type(result) is str)  # this only tests that command runs OK
Beispiel #52
0
 def test_picroft_docs(self, testbot):
     testbot.push_message('!picroft_docs')
     output = "The documentation for the picroft project can be found " \
              "here, https://github.com/MycroftAI/enclosure-picroft/wiki."
     assert output in testbot.pop_message()
Beispiel #53
0
 def test_message_callback(self, testbot):
     testbot.push_message('test it')
     assert 'Test Result' in testbot.pop_message()
Beispiel #54
0
 def test_desktop_clients(self, testbot):
     testbot.push_message('!desktop_clients')
     output = "The current list of mycroft desktop clients, " \
              "KDE: http://cgit.kde.org/plasma-mycroft.git/tree/Readme.md" \
              "Others: https://github.com/AIIX/Mycroft-AI-QtApplication"
     assert output in testbot.pop_message()
Beispiel #55
0
 def test_skills_available(self, testbot):
     testbot.push_message('!available_skills')
     output = "The current list of mycroft skills can be found here, " \
              "https://github.com/MycroftAI/mycroft-skills"
     assert output in testbot.pop_message()
Beispiel #56
0
 def test_mycroft_docs(self, testbot):
     testbot.push_message('!mycroft_docs')
     assert 'The mycroft documentation can be found at ' \
            'https://docs.mycroft.ai' in testbot.pop_message()
Beispiel #57
0
 def test_picroft_image(self, testbot):
     testbot.push_message('!picroft_image')
     output = "The image for the picroft project can be found here, "\
              "https://rebrand.ly/Picroft-0_8"
     assert output in testbot.pop_message()
Beispiel #58
0
 def test_wheel(self, testbot):
     testbot.push_message('!wheel')
     result = testbot.pop_message()
     assert (result == 'Yes' or result == 'No')
Beispiel #59
0
 def test_coinflip(self, testbot):
     testbot.push_message('!coinflip')
     result = testbot.pop_message()
     assert (result == 'HEADS!' or result == 'TAILS!')
Beispiel #60
0
 def test_install_qtapplication(self, testbot):
     testbot.push_message('!install_qtapplication')
     output = "Appimage for the standalone Qtapplication is available at" \
              "https://github.com/AIIX/Mycroft-Ai-QtApplication/releases"
     assert output in testbot.pop_message()