forked from cos-archives/osf-ui-tests
/
project_creation_tests.py
81 lines (61 loc) · 2.08 KB
/
project_creation_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
"""
Tests for creating projects.
"""
import unittest
from selenium import webdriver
from pymongo import MongoClient
# Project imports
import util
import config
class ProjectCreationTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.driver = util.launch_driver()
# Create user account and login
cls.user_data = util.create_user(cls.driver)
util.login(
cls.driver,
cls.user_data['username'],
cls.user_data['password']
)
@classmethod
def tearDownClass(cls):
#
cls.driver.close()
def test_create_project(self):
"""
test to make sure that creating a project works correctly
"""
# Create project with default args
util.create_project(self.driver)
#assert that the title and description above the same
#as the webpage
redirect_title = self.driver.find_element_by_xpath(
'//h1[@id="node-title-editable"]'
).text
redirect_description_all = self.driver.find_element_by_xpath(
'//p[@id="contributors"]'
).text
#theres a lot of text in this p element, so have to find
#where the description starts
index = redirect_description_all.find(config.project_description)
self.assertEqual(
redirect_description_all[index:],
config.project_description
)
self.assertEqual(redirect_title, config.project_title)
# Delete project
util.delete_project(self.driver)
def test_delete_project(self):
""" Test creating and then deleting a project. """
# Create a new project
util.create_project(self.driver)
# Delete the project
util.delete_project(self.driver)
# Get alert boxes
alerts = util.get_alert_boxes(self.driver, 'component(s) deleted')
# Must be exactly one matching alert
self.assertEqual(len(alerts), 1)
# Run tests
if __name__ == '__main__':
unittest.main()