#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
test_gitdl
----------------------------------
Tests for `gitdl` module.
"""

import os
import pytest

from gitdl import gitdl


class TestGitdl:

    def test_params_invalid_api_token(self):
        API_TOKEN = os.environ.get("GITDL")
        with pytest.raises(Exception):
            gitdl.get_params(API_TOKEN)

    def test_params_valid_api_token(self):
        API_TOKEN = os.environ.get("GITHUB_API_TOKEN")
        assert gitdl.get_params(API_TOKEN).get('API_TOKEN') == \
            os.environ.get("GITHUB_API_TOKEN")

@@ -146,16 +146,33 @@
 pytest%0A%0A
+import requests%0A%0A
 from git
@@ -333,16 +333,28 @@
 ception)
+ as exc_info
 :%0A      
@@ -386,16 +386,83 @@
 I_TOKEN)
+%0A        assert str(exc_info.value) == %22GITHUB_API_TOKEN not found%22
 %0A%0A    de
@@ -645,28 +645,360 @@
 ron.get(%22GITHUB_API_TOKEN%22)%0A
+%0A    def test_get_first_search_result_invalid(self):%0A        url = %22https://api.github.com/search/repositories?q=aksejake%22%0A        response = requests.get(url).json()%0A        with pytest.raises(Exception) as exc_info:%0A            gitdl.get_first_search_result(response)%0A        assert str(exc_info.value) == %22Repository Not Found.%22%0A

test for getting first search result