コード例 #1
0
    def test_remove_user_from_group(self):
        log = logging.getLogger()
        connection = Connection()
        connection.logger = log

        with open("../tests/get_teams.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        connection.connect(connection_params)

        # Komand-Test_Everyone
        # [email protected]
        try:
            add_user_to_group(log, connection,
                              "7af08a76-01fe-4a1d-bfa1-84d2b5509cdd",
                              "08290005-23ba-46b4-a377-b381d651a2fb")
            log.info("Successfully addeded user.")
        except Exception as e:
            log.info("Add user failed!")
            print(e)
            pass
        sleep(10)
        result = remove_user_from_group(
            log, connection, "7af08a76-01fe-4a1d-bfa1-84d2b5509cdd",
            "08290005-23ba-46b4-a377-b381d651a2fb")

        self.assertTrue(result)
コード例 #2
0
    def test_enable_teams_for_group(self):
        log = logging.getLogger()
        connection = Connection()
        connection.logger = log

        with open("../tests/get_teams.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        connection.connect(connection_params)

        # try nuking the group first, create_group fails if it's already there
        try:
            delete_group(logging, connection, "test_group_delete_me")
            sleep(10)  # give Azure time to do it's thing
        except Exception:
            pass

        result = create_group(log, connection, "test_group_delete_me",
                              "A test group to delete", "nickname_goes_here",
                              True, None, None)

        self.assertIsNotNone(result)
        self.assertEqual(result.get('displayName'), 'test_group_delete_me')
        self.assertEqual(result.get('description'), 'A test group to delete')

        group_id = result.get('id')
        success = enable_teams_for_group(log, connection, group_id)

        self.assertTrue(success)
コード例 #3
0
    def test_integration_get_team(self):
        log = logging.getLogger("Test")
        test_connection = Connection()
        test_connection.logger = log

        with open("../tests/send_message.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        test_connection.connect(connection_params)

        expected = "[Test] for customer"
        teams = get_teams_from_microsoft(log, test_connection, expected, True)
        self.assertEquals(teams[0].get("displayName"), expected)

        expected = "Dream Team"
        teams = get_teams_from_microsoft(log, test_connection, expected, True)
        self.assertEquals(teams[0].get("displayName"), expected)

        expected = "change_me"
        teams = get_teams_from_microsoft(log, test_connection, expected, True)
        self.assertEquals(teams[0].get("displayName"), expected)

        expected = "Komand-Test-Everyone"
        teams = get_teams_from_microsoft(log, test_connection, expected, True)
        self.assertEquals(teams[0].get("displayName"), expected)
コード例 #4
0
    def test_integration_delete_channel(self):
        log = logging.getLogger("Test")
        test_connection = Connection()
        test_connection.logger = log

        with open("../tests/send_message.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        test_connection.connect(connection_params)

        channels = get_channels_from_microsoft(log, test_connection, TEAM_ID, TEST_CHANNEL_NAME, True)
        channel_id = channels[0].get("id")

        result = delete_channel(log, test_connection, TEAM_ID, channel_id)

        # Leaving this code here - This can be used for bulk delete if needed

        # for i in range(100):
        #     channel_name = f"{i}_test_channel_3"
        #     channels = get_channels_from_microsoft(log, test_connection, TEAM_ID, channel_name)
        #     channel_id = channels[0].get("id")
        #     delete_channel(log, test_connection, TEAM_ID, channel_id)
        #     time.sleep(1)

        self.assertTrue(result)
コード例 #5
0
    def test_create_group(self):
        log = logging.getLogger()
        connection = Connection()
        connection.logger = log

        with open("../tests/get_teams.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        connection.connect(connection_params)

        owners = ["*****@*****.**"]
        members = [
            "*****@*****.**",
            "*****@*****.**"
        ]

        result = create_group(
            log,
            connection,
            "test_group_delete_me",
            "A test group to delete",
            "nickname_goes_here",
            True,
            owners,
            members,
        )

        self.assertIsNotNone(result)
        self.assertEqual(result.get("displayName"), "test_group_delete_me")
        self.assertEqual(result.get("description"), "A test group to delete")
コード例 #6
0
    def test_delete_group(self):
        log = logging.getLogger()
        connection = Connection()
        connection.logger = log

        with open("../tests/get_teams.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        connection.connect(connection_params)
        result = delete_group(log, connection, "test_group_delete_me")

        self.assertTrue(result)
コード例 #7
0
    def test_get_group_id(self):
        log = logging.getLogger()
        connection = Connection()
        connection.logger = log

        with open("../tests/get_teams.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        connection.connect(connection_params)
        result = get_group_id_from_name(log, connection,
                                        "test_group_delete_me")

        self.assertIsNotNone(result)
        self.assertEqual(type(result), str)
コード例 #8
0
    def test_create_channel(self):
        log = logging.getLogger("Test")
        test_connection = Connection()
        test_connection.logger = log

        with open("../tests/send_message.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        test_connection.connect(connection_params)

        result = create_channel(log, test_connection, TEAM_ID,
                                TEST_CHANNEL_NAME,
                                "some really cool test description")
        self.assertTrue(result)
コード例 #9
0
    def test_delete_channel(self):
        log = logging.getLogger("Test")
        test_connection = Connection()
        test_connection.logger = log

        with open("../tests/send_message.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        test_connection.connect(connection_params)

        channels = get_channels_from_microsoft(log, test_connection, TEAM_ID,
                                               TEST_CHANNEL_NAME)
        channel_id = channels[0].get("id")

        result = delete_channel(log, test_connection, TEAM_ID, channel_id)
        self.assertTrue(result)
コード例 #10
0
    def test_integration_negative_get_blank_team(self):
        log = logging.getLogger("Test")
        test_connection = Connection()
        test_connection.logger = log

        with open("../tests/send_message.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        test_connection.connect(connection_params)
        expected = ""
        with self.assertRaises(PluginException):
            teams = get_teams_from_microsoft(log, test_connection, expected, True)

        expected = "DONT FIND THIS"
        with self.assertRaises(PluginException):
            teams = get_teams_from_microsoft(log, test_connection, expected, True)
コード例 #11
0
    def test_integraion_create_channel(self):
        log = logging.getLogger("Test")
        test_connection = Connection()
        test_connection.logger = log

        with open("../tests/send_message.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        test_connection.connect(connection_params)

        result = create_channel(log, test_connection, TEAM_ID, TEST_CHANNEL_NAME, "some really cool test description")

        # This code is used to bulk create channels. Needed to max out a team with channels to test
        # pagination

        # for i in range(200):
        #     channel_name = f"{i}_test_channel"
        #     create_channel(log, test_connection, TEAM_ID, channel_name, "some really cool test description")

        self.assertTrue(result)
コード例 #12
0
    def test_get_user_info(self):
        log = logging.getLogger()
        connection = Connection()
        connection.logger = log

        with open("../tests/get_teams.json") as file:
            data = json.load(file)
            connection_params = data.get("body").get("connection")

        connection.connect(connection_params)

        result = get_user_info(log, connection,
                               "*****@*****.**")

        self.assertEqual("Joey McAdams", result.get("displayName"))
        self.assertEqual("08290005-23ba-46b4-a377-b381d651a2fb",
                         result.get("id"))

        result = get_user_info(log, connection,
                               "*****@*****.**")

        self.assertEqual("Jon Schipp", result.get("displayName"))
        self.assertEqual("ac785ffe-530a-45a1-bbf4-e275457e464b",
                         result.get("id"))