Exemplo n.º 1
0
    def test_old_client(self):
        old = (
            ','.join(('ankidesktop', '2.0.12', 'lin::')),
            ','.join(('ankidesktop', '2.0.26', 'lin::')),
            ','.join(('ankidroid', '2.1', '')),
            ','.join(('ankidroid', '2.2', '')),
            ','.join(('ankidroid', '2.2.2', '')),
            ','.join(('ankidroid', '2.3alpha3', '')),
        )

        current = (
            None,
            ','.join(('ankidesktop', '2.0.27', 'lin::')),
            ','.join(('ankidesktop', '2.0.32', 'lin::')),
            ','.join(('ankidesktop', '2.1.0', 'lin::')),
            ','.join(('ankidesktop', '2.1.6-beta2', 'lin::')),
            ','.join(('ankidesktop', '2.1.9 (dev)', 'lin::')),
            ','.join(
                ('ankidesktop', '2.1.26 (arch-linux-2.1.26-1)', 'lin:arch:')),
            ','.join(('ankidroid', '2.2.3', '')),
            ','.join(('ankidroid', '2.3alpha4', '')),
            ','.join(('ankidroid', '2.3alpha5', '')),
            ','.join(('ankidroid', '2.3beta1', '')),
            ','.join(('ankidroid', '2.3', '')),
            ','.join(('ankidroid', '2.9', '')),
        )

        for cv in old:
            if not SyncCollectionHandler._old_client(cv):
                raise AssertionError("old_client(\"%s\") is False" % cv)

        for cv in current:
            if SyncCollectionHandler._old_client(cv):
                raise AssertionError("old_client(\"%s\") is True" % cv)
Exemplo n.º 2
0
    def test_old_client(self):
        old = (
            ','.join(('ankidesktop', '2.0.12', 'lin::')),
            ','.join(('ankidesktop', '2.0.26', 'lin::')),
            ','.join(('ankidroid', '2.1', '')),
            ','.join(('ankidroid', '2.2', '')),
            ','.join(('ankidroid', '2.2.2', '')),
            ','.join(('ankidroid', '2.3alpha3', '')),
        )

        current = (
            None,
            ','.join(('ankidesktop', '2.0.27', 'lin::')),
            ','.join(('ankidesktop', '2.0.32', 'lin::')),
            ','.join(('ankidesktop', '2.1.0', 'lin::')),
            ','.join(('ankidesktop', '2.1.6-beta2', 'lin::')),
            ','.join(('ankidesktop', '2.1.9 (dev)', 'lin::')),
            ','.join(('ankidroid', '2.2.3', '')),
            ','.join(('ankidroid', '2.3alpha4', '')),
            ','.join(('ankidroid', '2.3alpha5', '')),
            ','.join(('ankidroid', '2.3beta1', '')),
            ','.join(('ankidroid', '2.3', '')),
            ','.join(('ankidroid', '2.9', '')),
        )

        for cv in old:
            if not SyncCollectionHandler._old_client(cv):
                raise AssertionError("old_client(\"%s\") is False" % cv)

        for cv in current:
            if SyncCollectionHandler._old_client(cv):
                raise AssertionError("old_client(\"%s\") is True" % cv)
Exemplo n.º 3
0
    def test_old_client(self):
        old = (
            ",".join(("ankidesktop", "2.0.12", "lin::")),
            ",".join(("ankidesktop", "2.0.26", "lin::")),
            ",".join(("ankidroid", "2.1", "")),
            ",".join(("ankidroid", "2.2", "")),
            ",".join(("ankidroid", "2.2.2", "")),
            ",".join(("ankidroid", "2.3alpha3", "")),
        )

        current = (
            None,
            ",".join(("ankidesktop", "2.0.27", "lin::")),
            ",".join(("ankidesktop", "2.0.32", "lin::")),
            ",".join(("ankidesktop", "2.1.0", "lin::")),
            ",".join(("ankidesktop", "2.1.6-beta2", "lin::")),
            ",".join(("ankidesktop", "2.1.9 (dev)", "lin::")),
            ",".join(("ankidroid", "2.2.3", "")),
            ",".join(("ankidroid", "2.3alpha4", "")),
            ",".join(("ankidroid", "2.3alpha5", "")),
            ",".join(("ankidroid", "2.3beta1", "")),
            ",".join(("ankidroid", "2.3", "")),
            ",".join(("ankidroid", "2.9", "")),
        )

        for cv in old:
            if not SyncCollectionHandler._old_client(cv):
                raise AssertionError('old_client("%s") is False' % cv)

        for cv in current:
            if SyncCollectionHandler._old_client(cv):
                raise AssertionError('old_client("%s") is True' % cv)
Exemplo n.º 4
0
class SyncCollectionHandlerTest(CollectionTestBase):
    def setUp(self):
        super().setUp()
        self.session = MagicMock()
        self.session.name = 'test'
        self.syncCollectionHandler = SyncCollectionHandler(
            self.collection, self.session)

    def tearDown(self):
        CollectionTestBase.tearDown(self)
        self.syncCollectionHandler = None

    def test_old_client(self):
        old = (
            ','.join(('ankidesktop', '2.0.12', 'lin::')),
            ','.join(('ankidesktop', '2.0.26', 'lin::')),
            ','.join(('ankidroid', '2.1', '')),
            ','.join(('ankidroid', '2.2', '')),
            ','.join(('ankidroid', '2.2.2', '')),
            ','.join(('ankidroid', '2.3alpha3', '')),
        )

        current = (
            None,
            ','.join(('ankidesktop', '2.0.27', 'lin::')),
            ','.join(('ankidesktop', '2.0.32', 'lin::')),
            ','.join(('ankidesktop', '2.1.0', 'lin::')),
            ','.join(('ankidesktop', '2.1.6-beta2', 'lin::')),
            ','.join(('ankidesktop', '2.1.9 (dev)', 'lin::')),
            ','.join(
                ('ankidesktop', '2.1.26 (arch-linux-2.1.26-1)', 'lin:arch:')),
            ','.join(('ankidroid', '2.2.3', '')),
            ','.join(('ankidroid', '2.3alpha4', '')),
            ','.join(('ankidroid', '2.3alpha5', '')),
            ','.join(('ankidroid', '2.3beta1', '')),
            ','.join(('ankidroid', '2.3', '')),
            ','.join(('ankidroid', '2.9', '')),
        )

        for cv in old:
            if not SyncCollectionHandler._old_client(cv):
                raise AssertionError("old_client(\"%s\") is False" % cv)

        for cv in current:
            if SyncCollectionHandler._old_client(cv):
                raise AssertionError("old_client(\"%s\") is True" % cv)

    def test_meta(self):
        meta = self.syncCollectionHandler.meta(v=SYNC_VER)
        self.assertEqual(meta['scm'], self.collection.scm)
        self.assertTrue((type(meta['ts']) == int) and meta['ts'] > 0)
        self.assertEqual(meta['mod'], self.collection.mod)
        self.assertEqual(meta['usn'], self.collection._usn)
        self.assertEqual(meta['uname'], self.session.name)
        self.assertEqual(meta['musn'], self.collection.media.lastUsn())
        self.assertEqual(meta['msg'], '')
        self.assertEqual(meta['cont'], True)
Exemplo n.º 5
0
class SyncCollectionHandlerTest(CollectionTestBase):
    def setUp(self):
        CollectionTestBase.setUp(self)
        self.syncCollectionHandler = SyncCollectionHandler(self.collection)

    def tearDown(self):
        CollectionTestBase.tearDown(self)
        self.syncCollectionHandler = None

    def test_old_client(self):
        old = (
            ','.join(('ankidesktop', '2.0.12', 'lin::')),
            ','.join(('ankidesktop', '2.0.26', 'lin::')),
            ','.join(('ankidroid', '2.1', '')),
            ','.join(('ankidroid', '2.2', '')),
            ','.join(('ankidroid', '2.2.2', '')),
            ','.join(('ankidroid', '2.3alpha3', '')),
        )

        current = (
            None,
            ','.join(('ankidesktop', '2.0.27', 'lin::')),
            ','.join(('ankidesktop', '2.0.32', 'lin::')),
            ','.join(('ankidesktop', '2.1.0', 'lin::')),
            ','.join(('ankidesktop', '2.1.6-beta2', 'lin::')),
            ','.join(('ankidesktop', '2.1.9 (dev)', 'lin::')),
            ','.join(('ankidroid', '2.2.3', '')),
            ','.join(('ankidroid', '2.3alpha4', '')),
            ','.join(('ankidroid', '2.3alpha5', '')),
            ','.join(('ankidroid', '2.3beta1', '')),
            ','.join(('ankidroid', '2.3', '')),
            ','.join(('ankidroid', '2.9', '')),
        )

        for cv in old:
            if not SyncCollectionHandler._old_client(cv):
                raise AssertionError("old_client(\"%s\") is False" % cv)

        for cv in current:
            if SyncCollectionHandler._old_client(cv):
                raise AssertionError("old_client(\"%s\") is True" % cv)

    def test_meta(self):
        meta = self.syncCollectionHandler.meta(v=SYNC_VER)
        self.assertEqual(meta['scm'], self.collection.scm)
        self.assertTrue((type(meta['ts']) == int) and meta['ts'] > 0)
        self.assertEqual(meta['mod'], self.collection.mod)
        self.assertEqual(meta['usn'], self.collection._usn)
        self.assertEqual(meta['musn'], self.collection.media.lastUsn())
        self.assertEqual(meta['msg'], '')
        self.assertEqual(meta['cont'], True)
Exemplo n.º 6
0
class SyncCollectionHandlerTest(CollectionTestBase):
    def setUp(self):
        CollectionTestBase.setUp(self)
        self.syncCollectionHandler = SyncCollectionHandler(self.collection)

    def tearDown(self):
        CollectionTestBase.tearDown(self)
        self.syncCollectionHandler = None

    def test_old_client(self):
        old = (
            ",".join(("ankidesktop", "2.0.12", "lin::")),
            ",".join(("ankidesktop", "2.0.26", "lin::")),
            ",".join(("ankidroid", "2.1", "")),
            ",".join(("ankidroid", "2.2", "")),
            ",".join(("ankidroid", "2.2.2", "")),
            ",".join(("ankidroid", "2.3alpha3", "")),
        )

        current = (
            None,
            ",".join(("ankidesktop", "2.0.27", "lin::")),
            ",".join(("ankidesktop", "2.0.32", "lin::")),
            ",".join(("ankidesktop", "2.1.0", "lin::")),
            ",".join(("ankidesktop", "2.1.6-beta2", "lin::")),
            ",".join(("ankidesktop", "2.1.9 (dev)", "lin::")),
            ",".join(("ankidroid", "2.2.3", "")),
            ",".join(("ankidroid", "2.3alpha4", "")),
            ",".join(("ankidroid", "2.3alpha5", "")),
            ",".join(("ankidroid", "2.3beta1", "")),
            ",".join(("ankidroid", "2.3", "")),
            ",".join(("ankidroid", "2.9", "")),
        )

        for cv in old:
            if not SyncCollectionHandler._old_client(cv):
                raise AssertionError('old_client("%s") is False' % cv)

        for cv in current:
            if SyncCollectionHandler._old_client(cv):
                raise AssertionError('old_client("%s") is True' % cv)

    def test_meta(self):
        meta = self.syncCollectionHandler.meta(v=SYNC_VER)
        self.assertEqual(meta["scm"], self.collection.scm)
        self.assertTrue((type(meta["ts"]) == int) and meta["ts"] > 0)
        self.assertEqual(meta["mod"], self.collection.mod)
        self.assertEqual(meta["usn"], self.collection._usn)
        self.assertEqual(meta["musn"], self.collection.media.lastUsn())
        self.assertEqual(meta["msg"], "")
        self.assertEqual(meta["cont"], True)
Exemplo n.º 7
0
class SyncCollectionHandlerTest(CollectionTestBase):
    def setUp(self):
        CollectionTestBase.setUp(self)
        self.syncCollectionHandler = SyncCollectionHandler(self.collection)

    def tearDown(self):
        CollectionTestBase.tearDown(self)
        self.syncCollectionHandler = None

    def test_old_client(self):
        old = (
            ','.join(('ankidesktop', '2.0.12', 'lin::')),
            ','.join(('ankidesktop', '2.0.26', 'lin::')),
            ','.join(('ankidroid', '2.1', '')),
            ','.join(('ankidroid', '2.2', '')),
            ','.join(('ankidroid', '2.2.2', '')),
            ','.join(('ankidroid', '2.3alpha3', '')),
        )

        current = (
            None,
            ','.join(('ankidesktop', '2.0.27', 'lin::')),
            ','.join(('ankidesktop', '2.0.32', 'lin::')),
            ','.join(('ankidesktop', '2.1.0', 'lin::')),
            ','.join(('ankidroid', '2.2.3', '')),
            ','.join(('ankidroid', '2.3alpha4', '')),
            ','.join(('ankidroid', '2.3alpha5', '')),
            ','.join(('ankidroid', '2.3beta1', '')),
            ','.join(('ankidroid', '2.3', '')),
            ','.join(('ankidroid', '2.9', '')),
        )

        for cv in old:
            if not old_client(cv):
                raise AssertionError("old_client(\"%s\") is False" % cv)

        for cv in current:
            if old_client(cv):
                raise AssertionError("old_client(\"%s\") is True" % cv)

    def test_meta(self):
        meta = self.syncCollectionHandler.meta()
        self.assertEqual(meta['scm'], self.collection.scm)
        self.assertTrue((type(meta['ts']) == int) and meta['ts'] > 0)
        self.assertEqual(meta['mod'], self.collection.mod)
        self.assertEqual(meta['usn'], self.collection._usn)
        self.assertEqual(meta['musn'], self.collection.media.lastUsn())
        self.assertEqual(meta['msg'], '')
        self.assertEqual(meta['cont'], True)
Exemplo n.º 8
0
 def setUp(self):
     CollectionTestBase.setUp(self)
     self.syncCollectionHandler = SyncCollectionHandler(self.collection)
Exemplo n.º 9
0
 def setUp(self):
     super().setUp()
     self.session = MagicMock()
     self.session.name = 'test'
     self.syncCollectionHandler = SyncCollectionHandler(
         self.collection, self.session)
Exemplo n.º 10
0
 def setUp(self):
     CollectionTestBase.setUp(self)
     self.syncCollectionHandler = SyncCollectionHandler(self.collection)