<commit_before>import unittest
import datetime

from goji.client import JIRAClient, JIRAException

from tests.server import JIRAServer


class ClientTests(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.server = JIRAServer()

    @classmethod
    def tearDownClass(cls):
        cls.server.shutdown()

    def setUp(self):
        self.client = JIRAClient(self.server.url)

    def test_post_400_error(self):
        self.server.response.status_code = 400
        self.server.response.body = {
            'errorMessages': ['Big Problem']
        }

        with self.assertRaises(JIRAException):
            self.client.post('path', {
                'body': 'example',
            })

    def test_get_user(self):
        self.server.response.body = {
            'name': 'kyle',
            'displayName': '<NAME>',
            'emailAddress': '<EMAIL>',
        }
        user = self.client.get_user()

        self.assertEqual(user.username, 'kyle')
        self.assertEqual(user.name, '<NAME>')
        self.assertEqual(user.email, '<EMAIL>')

        self.assertEqual(self.server.last_request.method, 'GET')
        self.assertEqual(self.server.last_request.path, '/rest/api/2/myself')

    def test_get_issue(self):
        self.server.response.body = {
            'key': 'GOJI-13',
            'fields': {
                'summary': 'Implement Client Unit Tests',
                'status': {
                    'name': 'open',
                }
            },
        }
        issue = self.client.get_issue('GOJI-13')

        self.assertEqual(issue.summary, 'Implement Client Unit Tests')

        self.assertEqual(self.server.last_request.method, 'GET')
        self.assertEqual(self.server.last_request.path, '/rest/api/2/issue/GOJI-13')

    def test_create_issue(self):
        self.server.response.body = {
            'key': 'GOJI-14',
        }

        self.client.create_issue({
            'summary': 'Test Creating Issues in JIRA Client',
        })

        self.assertEqual(self.server.last_request.method, 'POST')
        self.assertEqual(self.server.last_request.path, '/rest/api/2/issue')
        self.assertEqual(self.server.last_request.body, {
            'fields': {
                'summary': 'Test Creating Issues in JIRA Client',
            }
        })

    def test_edit_issue(self):
        self.client.edit_issue('GOJI-15', {
            'summary': 'Test Updating Issues in JIRA Client',
        })

        self.assertEqual(self.server.last_request.method, 'PUT')
        self.assertEqual(self.server.last_request.path, '/rest/api/2/issue/GOJI-15')
        self.assertEqual(self.server.last_request.body, {
            'fields': {
                'summary': 'Test Updating Issues in JIRA Client',
            }
        })

    def test_comment(self):
        self.server.response.body = {
            'key': 'GOJI-14',
        }

        self.client.comment('GOJI-14', 'Hello World')

        self.assertEqual(self.server.last_request.method, 'POST')
        self.assertEqual(self.server.last_request.path,
                         '/rest/api/2/issue/GOJI-14/comment')
        self.assertEqual(self.server.last_request.body, {
            'body': 'Hello World'
        })

    def test_create_sprint(self):
        self.server.response.status_code = 201

        self.client.create_sprint(5, 'Testing Sprint #1')

        self.assertEqual(self.server.last_request.path, '/rest/agile/1.0/sprint')
        self.assertEqual(self.server.last_request.body, {<commit_msg>test(client): Add coverage for assign<commit_after>import unittest
import datetime

from goji.client import JIRAClient, JIRAException

from tests.server import JIRAServer


class ClientTests(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.server = JIRAServer()

    @classmethod
    def tearDownClass(cls):
        cls.server.shutdown()

    def setUp(self):
        self.client = JIRAClient(self.server.url)

    def test_post_400_error(self):
        self.server.response.status_code = 400
        self.server.response.body = {
            'errorMessages': ['Big Problem']
        }

        with self.assertRaises(JIRAException):
            self.client.post('path', {
                'body': 'example',
            })

    def test_get_user(self):
        self.server.response.body = {
            'name': 'kyle',
            'displayName': '<NAME>',
            'emailAddress': '<EMAIL>',
        }
        user = self.client.get_user()

        self.assertEqual(user.username, 'kyle')
        self.assertEqual(user.name, '<NAME>')
        self.assertEqual(user.email, '<EMAIL>')

        self.assertEqual(self.server.last_request.method, 'GET')
        self.assertEqual(self.server.last_request.path, '/rest/api/2/myself')

    def test_get_issue(self):
        self.server.response.body = {
            'key': 'GOJI-13',
            'fields': {
                'summary': 'Implement Client Unit Tests',
                'status': {
                    'name': 'open',
                }
            },
        }
        issue = self.client.get_issue('GOJI-13')

        self.assertEqual(issue.summary, 'Implement Client Unit Tests')

        self.assertEqual(self.server.last_request.method, 'GET')
        self.assertEqual(self.server.last_request.path, '/rest/api/2/issue/GOJI-13')

    def test_create_issue(self):
        self.server.response.body = {
            'key': 'GOJI-14',
        }

        self.client.create_issue({
            'summary': 'Test Creating Issues in JIRA Client',
        })

        self.assertEqual(self.server.last_request.method, 'POST')
        self.assertEqual(self.server.last_request.path, '/rest/api/2/issue')
        self.assertEqual(self.server.last_request.body, {
            'fields': {
                'summary': 'Test Creating Issues in JIRA Client',
            }
        })

    def test_edit_issue(self):
        self.client.edit_issue('GOJI-15', {
            'summary': 'Test Updating Issues in JIRA Client',
        })

        self.assertEqual(self.server.last_request.method, 'PUT')
        self.assertEqual(self.server.last_request.path, '/rest/api/2/issue/GOJI-15')
        self.assertEqual(self.server.last_request.body, {
            'fields': {
                'summary': 'Test Updating Issues in JIRA Client',
            }
        })

    def test_assign(self):
        self.server.response.status_code = 204

        self.client.assign('GOJI-14', 'kyle')

        self.assertEqual(self.server.last_request.method, 'PUT')
        self.assertEqual(self.server.last_request.path,
                         '/rest/api/2/issue/GOJI-14/assignee')
        self.assertEqual(self.server.last_request.body, {'name': 'kyle'})

    def test_comment(self):
        self.server.response.body = {
            'key': 'GOJI-14',
        }

        self.client.comment('GOJI-14', 'Hello World')

        self.assertEqual(self.server.last_request.method, 'POST')
        self.assertEqual(self.server.last_request.path,
                         '/rest/api/2/issue/GOJI-14/comment')
        self.assertEqual(self.server.last_request.body, {
            'body': 'Hello World'
        })

    def test_create_sprint(self):
        self.server.response.status_code = 201

        self.client.create_sprint(5, 'Testing Sprint #1')

        self.assertEqual(self.server.last_request.path, '/rest/agile/1.0/sprint')
        self.assertEqual(self.server.last_request.body, {
{'fraction_non_alphanumeric': 0.13344933743809395, 'fraction_numerical': 0.010708071208673538, 'mean_word_length': 2.087603305785124, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5246777', 'n_tokens_mistral': 2337, 'n_tokens_neox': 2240, 'n_words': 343}