-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathclick_tests.py
More file actions
62 lines (46 loc) · 2.07 KB
/
click_tests.py
File metadata and controls
62 lines (46 loc) · 2.07 KB
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
import datetime
import unittest
from app.click.examples.eg001_create_clickwrap import Eg001CreateClickwrapController
from app.click.examples.eg002_activate_clickwrap import Eg002ActivateClickwrapController
from .test_helper import TestHelper, CONFIG, ApiType
class ClickTesting(unittest.TestCase):
@classmethod
def setUpClass(cls):
results = TestHelper.authenticate([ApiType.CLICK.value])
cls.access_token = results["access_token"]
cls.account_id = results["account_id"]
cls.base_path = results["base_path"]
def test_create_clickwrap_worker(self):
args = {
"account_id": self.account_id,
"access_token": self.access_token,
"clickwrap_name": f"{CONFIG['clickwrap_name']}_{int(datetime.datetime.utcnow().timestamp())}"
}
results = Eg001CreateClickwrapController.worker(args)
self.assertIsNotNone(results)
self.assertIsNotNone(results.clickwrap_id)
def test_activate_clickwrap_worker(self):
args = {
"account_id": self.account_id,
"base_path": self.base_path,
"access_token": self.access_token,
"statuses": ["inactive", "draft"]
}
results = Eg002ActivateClickwrapController.get_inactive_clickwraps(args)
clickwrap = results["clickwraps"][0]
clickwrap_args = f"{{\"clickwrap_id\": \"{clickwrap.clickwrap_id}\",\"version_number\": \"{clickwrap.version_number}\"}}"
args["clickwrap"] = clickwrap_args
results = Eg002ActivateClickwrapController.worker(args)
self.assertIsNotNone(results)
self.assertEqual(results.status, "active")
def test_activate_clickwrap_get_inactive_clickwraps(self):
args = {
"account_id": self.account_id,
"base_path": self.base_path,
"access_token": self.access_token,
"statuses": ["inactive", "draft"]
}
results = Eg002ActivateClickwrapController.get_inactive_clickwraps(args)
self.assertIsNotNone(results)
if __name__ == '__main__':
unittest.main()