<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import unittest

import responses

from slacker import (
    API_BASE_URL,
    Channels,
)


class TestUtils(unittest.TestCase):
    @responses.activate
    def test_get_channel_id(self):
        response = {
            'ok': 'true',
            'channels': [
                {'name': 'general', 'id': 'C111'},
                {'name': 'random', 'id': 'C222'}
            ]
        }
        responses.add(
            responses.GET,
            API_BASE_URL.format(api='channels.list'),
            json=response,
            status=200
        )
        channels = Channels(token='aaa')
        self.assertEqual(
            'C111', channels.get_channel_id('general')
        )

    @responses.activate
    def test_get_channel_id_without_channel(self):
        response = {
            'ok': 'true',
            'channels': [
                {'name': 'general', 'id': 'C111'},
                {'name': 'random', 'id': 'C222'}
            ]
        }
        responses.add(
            responses.GET,
            API_BASE_URL.format(api='channels.list'),
            json=response,
            status=200
        )
        channels = Channels(token='aaa')
        self.assertEqual(
            None, channels.get_channel_id('fake_group')
        )<commit_msg>Fix Yoda conditions<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import unittest

import responses

from slacker import (
    API_BASE_URL,
    Channels,
)


class TestUtils(unittest.TestCase):
    @responses.activate
    def test_get_channel_id(self):
        response = {
            'ok': 'true',
            'channels': [
                {'name': 'general', 'id': 'C111'},
                {'name': 'random', 'id': 'C222'}
            ]
        }
        responses.add(
            responses.GET,
            API_BASE_URL.format(api='channels.list'),
            json=response,
            status=200
        )
        channels = Channels(token='aaa')
        self.assertEqual(channels.get_channel_id('general'), 'C111')

    @responses.activate
    def test_get_channel_id_without_channel(self):
        response = {
            'ok': 'true',
            'channels': [
                {'name': 'general', 'id': 'C111'},
                {'name': 'random', 'id': 'C222'}
            ]
        }
        responses.add(
            responses.GET,
            API_BASE_URL.format(api='channels.list'),
            json=response,
            status=200
        )
        channels = Channels(token='aaa')
        self.assertEqual(channels.get_channel_id('fake_group'), None)
{'fraction_non_alphanumeric': 0.13795731707317074, 'fraction_numerical': 0.01676829268292683, 'mean_word_length': 1.7033985581874356, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '624473', 'n_tokens_mistral': 796, 'n_tokens_neox': 756, 'n_words': 132}