if sync server offline, abort sync tests

This commit is contained in:
Damien Elmes 2011-10-01 20:44:35 +09:00
parent f131021c7e
commit bf3bb9dd32
3 changed files with 18 additions and 1 deletions

View file

@ -8,6 +8,7 @@ from anki.consts import *
from anki.lang import _
# fixmes:
# - make sure users can't set grad interval < 1
# - make sure lists like new[delays] are not being shared by multiple groups
# - make sure all children have parents (create as necessary)
# - when renaming a group, top level properties should be added or removed as

View file

@ -22,6 +22,8 @@ SYNC_PORT = int(os.environ.get("SYNC_PORT") or 80)
SYNC_URL = "http://%s:%d/sync/" % (SYNC_HOST, SYNC_PORT)
SYNC_VER = 0
# - 64 bit guid will be munged in js; need to escape or rethink
# - make sure /sync/download is compressed
# - status() should be using the hooks instead

View file

@ -256,6 +256,7 @@ anki.sync.SYNC_URL = "http://localhost:8001/sync/"
TEST_USER = "synctest@ichi2.net"
TEST_PASS = "synctest"
TEST_HKEY = "k14LvSaEtXFITCJz"
TEST_REMOTE = True
def setup_remote():
global server
@ -267,7 +268,14 @@ def setup_remote():
@nose.with_setup(setup_remote)
def test_meta():
global TEST_REMOTE
try:
(mod, scm, usn, ts) = server.meta()
except Exception, e:
if e.errno == 61:
TEST_REMOTE = False
print "aborting; server offline"
return
assert mod
assert scm
assert mod != client.deck.mod
@ -275,6 +283,8 @@ def test_meta():
@nose.with_setup(setup_remote)
def test_hkey():
if not TEST_REMOTE:
return
assertException(Exception, lambda: server.hostKey("wrongpass"))
server.hkey = "abc"
k = server.hostKey(TEST_PASS)
@ -282,6 +292,8 @@ def test_hkey():
@nose.with_setup(setup_remote)
def test_download():
if not TEST_REMOTE:
return
f = FullSyncer(client.deck, "abc")
assertException(Exception, f.download)
f.hkey = TEST_HKEY
@ -289,6 +301,8 @@ def test_download():
@nose.with_setup(setup_remote)
def test_remoteSync():
if not TEST_REMOTE:
return
# not yet associated, so will require a full sync
assert client.sync() == "fullSync"
# upload