forked from InstaPy/InstaPy
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtests.py
81 lines (66 loc) · 2.67 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import os
import sys
import time
import arrow
import unittest
from instapy import InstaPy
from quickstart import *
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from elasticsearch import Elasticsearch
insta_username = 'zeusfsx'
insta_password = 'instagrambot'
class PythonInstagram(unittest.TestCase):
test_session = None
test_usernames = ['art_didus']
def test_acreating_chromedriver(self):
PythonInstagram.test_session = InstaPy(username=insta_username, password=insta_password, nogui=True)
utc = arrow.utcnow()
if PythonInstagram.test_session:
print("\nTest 'InstaPy()' PASS at " + str(utc))
else:
print("\nTest 'InstaPy()' FAIL at " + str(utc))
send_email("Test 'InstaPy()' FAIL at " + str(utc))
def test_blogin(self):
loginner = PythonInstagram.test_session.login()
utc = arrow.utcnow()
if isinstance(loginner, InstaPy):
print("\nTest 'login' PASS at " + str(utc))
else:
print("\nTest 'login' FAIL at " + str(utc))
send_email("Test 'login' FAIL at " + str(utc))
def test_caccounts_to_json(self):
id_news = ['1738744946298415600', '1788357238303626994']
PythonInstagram.test_session.accounts_to_json(PythonInstagram.test_usernames)
res = check_Elastic(id_news)
utc = arrow.utcnow()
if res == 2:
print("\nTest 'accounts_to_json' PASS at " + str(utc))
else:
print("\nTest 'accounts_to_json' FAIL at " + str(utc))
send_email("Test 'accounts_to_json' FAIL at " + str(utc))
def test_dend(self):
PythonInstagram.test_session.end()
brouwser = PythonInstagram.test_session.get_browser()
utc = arrow.utcnow()
try:
brouwser.get('https://www.google.com.ua')
print("\nTest 'InstaPy()' FAIL at " + str(utc))
send_email("Test 'InstaPy()' FAIL at " + str(utc))
except:
print("\nTest 'InstaPy()' PASS at " + str(utc))
def check_Elastic(id_news: list)->int:
es = Elasticsearch(
['media-audit.com'],
http_auth=('elastic', 'changeme'),
port=9200
)
res = es.search('instagram', 'local', body={"query": {
"ids" : {
"values" : id_news
}
}
})
return res['hits']['total']
if __name__ == "__main__":
unittest.main()