Skip to content

Commit

Permalink
Merge pull request #50 from KingAkeem/dev
Browse files Browse the repository at this point in the history
Switched testing framework from unittest to pytest
  • Loading branch information
PSNAppz authored Jan 14, 2018
2 parents 486423d + a9a100c commit e591b18
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 80 deletions.
15 changes: 0 additions & 15 deletions sample.py

This file was deleted.

21 changes: 5 additions & 16 deletions tests/test_getemails.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import os
import unittest

PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(
Expand All @@ -9,22 +8,12 @@
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))

from modules import pagereader, getemails
from modules.bcolors import Bcolors


soup = pagereader.readPage('http://www.whatsmyip.net/')
def test_get_emails_successful():
soup = pagereader.readPage('http://www.whatsmyip.net/')
test_emails = ["advertise@provaz.eu"]
emails = getemails.getMails(soup)
assert emails == test_emails


class getMailsTestCase(unittest.TestCase):

def setUp(self):
self.b_colors = Bcolors()

def test_getemails(self):
test_emails = ["advertise@provaz.eu"]
emails = getemails.getMails(soup)
self.assertEqual(emails, test_emails)


if __name__ == '__main__':
unittest.main()
32 changes: 8 additions & 24 deletions tests/test_getweblinks.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
#!/usr/bin/env python

import unittest
import sys
import os
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(
os.path.join(os.getcwd(), os.path.expanduser(__file__))))

sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
from io import StringIO
from modules.bcolors import Bcolors
from modules import getweblinks, pagereader

soup = pagereader.readPage('http://www.whatsmyip.net/')

def test_get_links_successful():
soup = pagereader.readPage('http://www.whatsmyip.net/')
data = ['http://aff.ironsocket.com/SH7L',
'http://aff.ironsocket.com/SH7L',
'http://wsrs.net/',
'http://cmsgear.com/']

class getLinksTestCase(unittest.TestCase):

def setUp(self):
self.b_colors = Bcolors()
self.held, sys.stdout = sys.stdout, StringIO()
self.maxDiff = None

def test_get_links(self):

data = ['http://aff.ironsocket.com/SH7L',
'http://aff.ironsocket.com/SH7L',
'http://wsrs.net/',
'http://cmsgear.com/']

result = getweblinks.getLinks(soup)
self.assertEqual(result, data)


if __name__ == '__main__':
unittest.main()
result = getweblinks.getLinks(soup)
assert result == data
33 changes: 8 additions & 25 deletions tests/test_savetofile.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,19 @@
import sys
import os
import unittest
import time
PACKAGE_PARENT = '..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(
os.path.join(os.getcwd(), os.path.expanduser(__file__))))

sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))

from io import StringIO
from modules.bcolors import Bcolors
from modules import getweblinks, pagereader

soup = pagereader.readPage('http://www.whatsmyip.net/')
timestr = time.strftime("%Y%m%d-%H%M%S")


class getLinksTestCase(unittest.TestCase):

def setUp(self):
self.held, sys.stdout = sys.stdout, StringIO()
self.maxDiff = None
self.b_colors = Bcolors()

def test_save_links(self):
data = ['http://aff.ironsocket.com/SH7L',
'http://aff.ironsocket.com/SH7L',
'http://wsrs.net/',
'http://cmsgear.com/']
result = getweblinks.getLinks(soup)
self.assertEqual(result, data)


if __name__ == '__main__':
unittest.main()
def test_save_links_successful():
soup = pagereader.readPage('http://www.whatsmyip.net/')
data = ['http://aff.ironsocket.com/SH7L',
'http://aff.ironsocket.com/SH7L',
'http://wsrs.net/',
'http://cmsgear.com/']
result = getweblinks.getLinks(soup)
assert result == data

0 comments on commit e591b18

Please sign in to comment.