Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move modulestates to schema initialization #136

Merged
merged 2 commits into from
Aug 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions cnxpublishing/tests/scripts/test_post_publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ def setUp(self, cursor):
archive_initdb(archive_settings)
initdb(self.db_conn_str)

# Insert modulestates
cursor.execute("""\
INSERT INTO modulestates (stateid, statename) VALUES
(0, 'unknown'),
(1, 'current'),
(4, 'obsolete'),
(5, 'post-publication'),
(6, 'processing'),
(7, 'errored');""")

def tearDown(self):
# Terminate the post publication worker script.
if self.process.is_alive():
Expand Down
10 changes: 0 additions & 10 deletions cnxpublishing/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,6 @@ def setUp(self, cursor):
from openstax_accounts.stub import main
main(self.config)

# Insert modulestates
cursor.execute("""\
INSERT INTO modulestates (stateid, statename) VALUES
(0, 'unknown'),
(1, 'current'),
(4, 'obsolete'),
(5, 'post-publication'),
(6, 'processing'),
(7, 'errored');""")

def tearDown(self):
with psycopg2.connect(self.db_conn_str) as db_conn:
with db_conn.cursor() as cursor:
Expand Down
25 changes: 6 additions & 19 deletions cnxpublishing/tests/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ def setUp(self):
initdb(self.db_conn_str)
self.config = testing.setUp(settings=self.settings)

# Insert modulestates
with self.db_connect() as db_conn:
with db_conn.cursor() as cursor:
cursor.execute("""\
INSERT INTO modulestates (stateid, statename)
VALUES (1, 'current')""")

def tearDown(self):
with psycopg2.connect(self.db_conn_str) as db_conn:
with db_conn.cursor() as cursor:
Expand Down Expand Up @@ -492,18 +485,6 @@ def setUp(self):
initdb(self.db_conn_str)
self.config = testing.setUp(settings=self.settings)

# Insert modulestates
with psycopg2.connect(self.db_conn_str) as db_conn:
with db_conn.cursor() as cursor:
cursor.execute("""\
INSERT INTO modulestates (stateid, statename) VALUES
(0, 'unknown'),
(1, 'current'),
(4, 'obsolete'),
(5, 'post-publication'),
(6, 'processing'),
(7, 'errored');""")

def tearDown(self):
with psycopg2.connect(self.db_conn_str) as db_conn:
with db_conn.cursor() as cursor:
Expand Down Expand Up @@ -626,6 +607,12 @@ def test_republish_binder_tree_not_latest(self, cursor):
# updated causing this book to be republished.
book_one = use_cases.setup_COMPLEX_BOOK_ONE_in_archive(self, cursor)

# Post publication worker will change the collection stateid to
# "current" (1).
cursor.execute("""\
UPDATE modules SET stateid = 1 WHERE stateid = 5""")
cursor.connection.commit()

# * Set the latest flag in trees for book one to null.
cursor.execute("""\
UPDATE trees SET latest = NULL WHERE documentid = (
Expand Down
12 changes: 0 additions & 12 deletions cnxpublishing/tests/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,6 @@ def setUp(self):
# Assign API keys for testing
self.set_up_api_keys()

# Insert modulestates
with self.db_connect() as db_conn:
with db_conn.cursor() as cursor:
cursor.execute("""\
INSERT INTO modulestates (stateid, statename) VALUES
(0, 'unknown'),
(1, 'current'),
(4, 'obsolete'),
(5, 'post-publication'),
(6, 'processing'),
(7, 'errored');""")

def tearDown(self):
with self.db_connect() as db_conn:
with db_conn.cursor() as cursor:
Expand Down