from __future__ import unicode_literals

import pytest

from .test_bot import TestBot


class TestBotSupport(TestBot):

    @pytest.mark.parametrize('url,result', [
        ('https://google.com', ['https://google.com']),
        ('google.com', ['google.com']),
        ('google.com/search?q=instabot', ['google.com/search?q=instabot']),
        ('https://google.com/search?q=instabot', ['https://google.com/search?q=instabot']),
        ('мвд.рф', ['мвд.рф']),
        ('https://мвд.рф', ['https://мвд.рф']),
        ('http://мвд.рф/news/', ['http://мвд.рф/news/']),
        ('hello, google.com/search?q=test and bing.com', ['google.com/search?q=test', 'bing.com']),
    ])
    def test_extract_urls(self, url, result):
        assert self.BOT.extract_urls(url) == result

from __future__ import unicode_literals

import os

import pytest

from .test_bot import TestBot


class TestBotSupport(TestBot):

    @pytest.mark.parametrize('url,result', [
        ('https://google.com', ['https://google.com']),
        ('google.com', ['google.com']),
        ('google.com/search?q=instabot', ['google.com/search?q=instabot']),
        ('https://google.com/search?q=instabot', ['https://google.com/search?q=instabot']),
        ('мвд.рф', ['мвд.рф']),
        ('https://мвд.рф', ['https://мвд.рф']),
        ('http://мвд.рф/news/', ['http://мвд.рф/news/']),
        ('hello, google.com/search?q=test and bing.com', ['google.com/search?q=test', 'bing.com']),
    ])
    def test_extract_urls(self, url, result):
        assert self.BOT.extract_urls(url) == result

    def test_check_if_file_exist(self):
        test_file = open('test', 'w')

        assert self.BOT.check_if_file_exists('test')

        test_file.close()
        os.remove('test')

    def test_check_if_file_exist_fail(self):
        assert not self.BOT.check_if_file_exists('test')

Add test on check file if exist
Add test on check file if exist

  from __future__ import unicode_literals
+ 
+ import os
  
  import pytest
  
  from .test_bot import TestBot
  
  
  class TestBotSupport(TestBot):
  
      @pytest.mark.parametrize('url,result', [
          ('https://google.com', ['https://google.com']),
          ('google.com', ['google.com']),
          ('google.com/search?q=instabot', ['google.com/search?q=instabot']),
          ('https://google.com/search?q=instabot', ['https://google.com/search?q=instabot']),
          ('мвд.рф', ['мвд.рф']),
          ('https://мвд.рф', ['https://мвд.рф']),
          ('http://мвд.рф/news/', ['http://мвд.рф/news/']),
          ('hello, google.com/search?q=test and bing.com', ['google.com/search?q=test', 'bing.com']),
      ])
      def test_extract_urls(self, url, result):
          assert self.BOT.extract_urls(url) == result
  
+     def test_check_if_file_exist(self):
+         test_file = open('test', 'w')
+ 
+         assert self.BOT.check_if_file_exists('test')
+ 
+         test_file.close()
+         os.remove('test')
+ 
+     def test_check_if_file_exist_fail(self):
+         assert not self.BOT.check_if_file_exists('test')
+ 
Add test on check file if exist
## Code Before:
from __future__ import unicode_literals

import pytest

from .test_bot import TestBot


class TestBotSupport(TestBot):

    @pytest.mark.parametrize('url,result', [
        ('https://google.com', ['https://google.com']),
        ('google.com', ['google.com']),
        ('google.com/search?q=instabot', ['google.com/search?q=instabot']),
        ('https://google.com/search?q=instabot', ['https://google.com/search?q=instabot']),
        ('мвд.рф', ['мвд.рф']),
        ('https://мвд.рф', ['https://мвд.рф']),
        ('http://мвд.рф/news/', ['http://мвд.рф/news/']),
        ('hello, google.com/search?q=test and bing.com', ['google.com/search?q=test', 'bing.com']),
    ])
    def test_extract_urls(self, url, result):
        assert self.BOT.extract_urls(url) == result

## Instruction:
Add test on check file if exist
## Code After:
from __future__ import unicode_literals

import os

import pytest

from .test_bot import TestBot


class TestBotSupport(TestBot):

    @pytest.mark.parametrize('url,result', [
        ('https://google.com', ['https://google.com']),
        ('google.com', ['google.com']),
        ('google.com/search?q=instabot', ['google.com/search?q=instabot']),
        ('https://google.com/search?q=instabot', ['https://google.com/search?q=instabot']),
        ('мвд.рф', ['мвд.рф']),
        ('https://мвд.рф', ['https://мвд.рф']),
        ('http://мвд.рф/news/', ['http://мвд.рф/news/']),
        ('hello, google.com/search?q=test and bing.com', ['google.com/search?q=test', 'bing.com']),
    ])
    def test_extract_urls(self, url, result):
        assert self.BOT.extract_urls(url) == result

    def test_check_if_file_exist(self):
        test_file = open('test', 'w')

        assert self.BOT.check_if_file_exists('test')

        test_file.close()
        os.remove('test')

    def test_check_if_file_exist_fail(self):
        assert not self.BOT.check_if_file_exists('test')
